-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
At the moment it is not possible to create an auth client within a nextjs app because the @8base/web-auth0-auth-client package uses the window object which is not defined in a ssr context.
This is my code:
const origin = typeof window !== 'undefined' ? window.location.origin : '';
const authClient = Auth.createClient(
{
strategy: AUTH_STRATEGIES.WEB_8BASE,
subscribable: true,
},
{
clientId: process.env.NEXT_PUBLIC_APP_AUTH_CLIENT_ID,
domain: process.env.NEXT_PUBLIC_APP_AUTH_CLIENT_ID,
redirectUri: `${origin}/auth/callback/path`,
logoutRedirectUri: `${origin}/`,
}
);It fails with an error that window is not defined.
The problem seems to be in web-auth0-auth-client/dist/WebAuth0AuthClient:
constructor(options, storage = window.localStorage, storageKey = 'auth')
when you check if the window exists, everything works fine.
Metadata
Metadata
Assignees
Labels
No labels