Reputation: 1822
I have 2 components on separate pages in nextjs. The way I would like my app to work is:
Below the component provided by the external service for reference:
<WebSdk
accessToken={token}
expirationHandler={handler}
config={config}
options={options}
onMessage={messageHandler}
onError={errorHandler}
/>
How should I store and read the access token? Do I need to use useState
or useEffect
? Do I need to set a cookie or localStorage?
Upvotes: 2
Views: 551
Reputation: 2341
Neither useState
nor useEffect
is good choice for this condition.
You can use both cookies(low security)
and localStorage
, but I recommend using sessionStorage(it has expire time)
.I
Upvotes: 1