react-oauth2-code-pkce
Advanced tools
Comparing version 1.22.1 to 1.22.2
@@ -120,4 +120,3 @@ "use strict"; | ||
function handleExpiredRefreshToken(initial = false) { | ||
// If it's the first page load, OR there is no sessionExpire callback, we trigger a new login | ||
if (initial) | ||
if (config.autoLogin && initial) | ||
return logIn(undefined, undefined, config.loginMethod); | ||
@@ -124,0 +123,0 @@ // TODO: Breaking change - remove automatic login during ongoing session |
{ | ||
"name": "react-oauth2-code-pkce", | ||
"version": "1.22.1", | ||
"version": "1.22.2", | ||
"description": "Provider agnostic react package for OAuth2 Authorization Code flow with PKCE", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -197,6 +197,27 @@ # react-oauth2-code-pkce | ||
### Fails to compile with Next.js | ||
The library's main componet `AuthProvider` is _client side only_. Meaning it must be rendered in a web browser, and can not be pre-rendered server-side (which is default in newer versions of NextJS and similar frameworks). | ||
This library expects to have a `localStorage` (or `sessionStorage`) available. That is not the case when compiling Next.js projects serverside. | ||
See: https://github.com/soofstad/react-oauth2-pkce/discussions/90 for a solution. | ||
This can be solved by marking the module with `use client` and importing the component in the client only (`"ssr": false`). | ||
```tsx | ||
'use client' | ||
import {useContext} from "react"; | ||
import dynamic from 'next/dynamic' | ||
import {TAuthConfig,TRefreshTokenExpiredEvent, AuthContext} from 'react-oauth2-code-pkce' | ||
const AuthProvider = dynamic( | ||
()=> import("react-oauth2-code-pkce") | ||
.then((mod) => mod.AuthProvider), | ||
{ssr: false} | ||
) | ||
const authConfig: TAuthConfig = {...for you to fill inn} | ||
export default function Authenticated() { | ||
(<AuthProvider authConfig={authConfig}> | ||
<LoginInfo/> | ||
</AuthProvider>) | ||
} | ||
``` | ||
### Error `Bad authorization state...` | ||
@@ -203,0 +224,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54450
254
810