Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I store server-side data on github?

I am using Github pages to build a website, but I can't figure out how to store data on the server-side. I can use localStorage and sessionStorage, but those are client-side. Does anyone have a way to use javascript or another programming language that works on Github to store data? Or can static websites not store data?

I have already googled "server-side Github" and "javascript server-side" and researched other programming languages like PHP(doesn't work on Github)

like image 328
cs641311 Avatar asked Feb 28 '26 07:02

cs641311


1 Answers

Static websites would need to communicate with a server through an API to store data. You could run that server yourself or use a third-party service to do it. If you're just starting out and prototyping a new app, it makes sense to leverage existing services as much as possible to validate your product.

If you've been using localStorage on the client-side and want a similar API where the data is stored on a server, I recommend looking into a remote key-value store like KVdb.io (disclaimer: I built it, but it's free to use!).

For example:

<script src="https://unpkg.com/[email protected]"></script>
<script>
const kvdbStorage = KVdb.bucket('MY_BUCKET_ID').localStorage()

kvdbStorage.setItem('my-key', 'my-value')
  .then(() => console.log('key saved')
  .then(() => kvdbStorage.getItem('my-key'))
  .then(value => console.log('get value', value))
  .catch(err => console.error(err)
</script>

If your data can be modeled as key-value pairs, this approach can get you pretty far without having to manage a database yourself.

like image 174
amir Avatar answered Mar 02 '26 05:03

amir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!