Next.js: Persist Data on Auth

Created on 11 Jan 2018  路  6Comments  路  Source: vercel/next.js

Hi, there is any way to persist the data on refresh page? i am looking with no luck, the last resort is asking here. thanks in advance.

Most helpful comment

Cookies are the way to go.
https://www.npmjs.com/package/next-cookies might help.

All 6 comments

You might want to use localstorage if you want to persist data on a page refresh. Especially when dealing with auth tokens. LocalForage is create for this. It uses the available best method for saving to localstorage.

Cookies might be a better shout if you want them on initial request to perform server side renders.

When you use cookies they are attached to the request, whereas local storage requires you wait for the page and javascript to be loaded, parsed and executed then the requests made.

Cookie is better if SSR auth is necessary.

Cookies are the way to go.
https://www.npmjs.com/package/next-cookies might help.

@epileftro85
You can checkout our boilerplate:
https://arefaslani.github.io/next-boilerplate
it's already configured to read and write cookies on server and client. Also it provides many options configured with Next.

@arefaslani i will take a look on it, thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kenji4569 picture kenji4569  路  3Comments

pie6k picture pie6k  路  3Comments

olifante picture olifante  路  3Comments

swrdfish picture swrdfish  路  3Comments

knipferrc picture knipferrc  路  3Comments