Store data for an account with Replit Auth?

Is there a way to store your own data for someone’s account with Replit auth?
For example, a website where you sign in with Repit Auth, then you can select a theme for the website, which is stored on that user’s account.
Right now all I know is how to GET a user’s data, not store anything.
Any help?


You cannot store data with Repl Auth but you can store data with a Replit db. Implementation varies by language. You must have a backend for your website (anything but the HTML/CSS/JS template). NodeJS and Python Flask are both good choices.

1 Like

Hey @TinyMooshmallow! Welcome back into the community!

You can store an account’s data using the window.localStorage property.

To use window.localStorage, you can use localStorage.setItem() (you can leave out the window part from your code) like this:

// ...fetched user data

Then you can use localStorage.getItem() to get the data:


Hope this helps!


This works well but is local, so it will not persist from one device to another.


@TinyMooshmallow meant that he wanted to store data on the user’s device and reuse that whenever the user logs in, like how websites allow the user to log into their account without signing in again with their username and password.


I tried that, but how to I access the replit database from the frontend?
“require” is not defined, so I can’t install the db.

You can’t. You can’t access stuff like DBs from the frontend.

1 Like

This Repl I made could be easily tweaked to write stuff to a DB instead of a text file.

Here you go! Make sure to change line 7 in templates/auth.html to whatever URL you need. Change the / in location.replace('/') to a different URL if desired. Note that to use this you will have to fork it, create a DB as instructed on line 6, add your Replit @ mention name to the list on line 11, and then open the site in a new tab or window (just don’t use the webview).
@QwertyQwerty88 It was easy.

What do you mean? You made that with a backend, not with the frontend…

But I made a frontend that edits the DB. My impression was that you thought that no frontend could ever touch a DB.

It can’t, though?

I’m guessing update() changes the value of a key

So you just updated the DB in the backend, not the frontend…


I guess it’s a matter of opinion. The frontend feeds data to the backend. The backend, using data from the frontend, updates the DB. So, it’s all in how you look at it. update() adds the item to the dictionary (or replaces it if it exists).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.