accounts
accounts copied to clipboard
localStorage is not defined - with SSR (NextJS)
Trying to use with NextJS and I'm getting "localStorage is not defined". Should be an easy enough fix. I can try and submit a PR if you would like
ReferenceError: localStorage is not defined
at Object.<anonymous> (/Users/scotttolinski/Sites/levelup/node_modules/apollo-accounts-password-client/node_modules/@accounts/client/lib/token-storage-local.js:49:39)
@stolinski Please do!! I'm currently looking to do the same thing, would really appreciate your PR! I'm sure @pradel will be happy to review and merge it too! Could make a nice example, and be on the docs/homepage.
I think it should be fairly easy to pass a different storage like in the cookbook for react-native:
import AsyncStorage from '@react-native-community/async-storage'; import { AccountsClient } from '@accounts/client'; const accounts = new AccountsClient({ // We tell the accounts-js client to use AsyncStorage to store the tokens tokenStorage: AsyncStorage, });
but with the proper cookieStorage
edit: Something like mixing these: https://github.com/zeit/next.js/tree/canary/examples/with-cookie-auth https://accounts-js.netlify.com/docs/cookbook/react-native
The solution would be to just check to see if localStorage exists before calling it. Unfortunately, I haven't had the time to dive in yet as I was unable to get started with the repos locally following the getting started docs. I need to find some time to dedicate to figuring that out.
The solution would be to just check to see if localStorage exists before calling it.
I think @pradel already fixed this on my PR
Unfortunately, I haven't had the time to dive in yet as I was unable to get started with the repos locally following the getting started docs. I need to find some time to dedicate to figuring that out.
I’m on a cruiseship in a transatlantic trip, so my wifi sux big time! But please tell me how can I help you @stolinski. I’ve had to use npm install and not yarn in some of the packages for them to work in my local machine. And also use yarn link to use some local packages like @accounts/client to test the nextJS example with the cookie storage ;)
There are someone example the accountsjs con nextjs ? if exists could you help me