Bot releases are visible (Hide)
Published by github-actions[bot] over 3 years ago
useSession
hook now returns an object. Here is how to accommodate for this change:- const [ session, loading ] = useSession()
+ const { data: session, status } = useSession()
+ const loading = status === "loading"
With the new status
option, you can test states much more clearly.
Published by github-actions[bot] over 3 years ago
callbacks
method signatures are changing the following way:- signIn(user, account, profileOrEmailOrCredentials)
+ signIn({ user, account, profile, email, credentials })
- redirect(url, baseUrl)
+ redirect({ url, baseUrl })
- session(session, tokenOrUser)
+ session({ session, token, user })
- jwt(token, user, account, OAuthProfile, isNewUser)
+ jwt({ token, user, account, profile, isNewUser })
NOTE: You only need to define the params that you actually need (no more need for
_
params.)
This way, if you only need token
and account
in the jwt
callback, you can write:
jwt({ token, account }) {
if(account) {
token.accessToken = account.access_token
}
return token
}
Published by github-actions[bot] over 3 years ago
Published by github-actions[bot] over 3 years ago
Published by github-actions[bot] over 3 years ago
Published by github-actions[bot] over 3 years ago
Published by github-actions[bot] over 3 years ago
1. next-auth/client
is renamed to next-auth/react
.
2. In the past, we exposed most of the functions with different names for convenience. To simplify our source code, the new React specific client code exports only the following functions, listed with the necessary changes:
setOptions
: Not exposed anymore, use SessionProvider
propsoptions
: Not exposed anymore, use SessionProvider
propssession
: Rename to getSession
providers
: Rename to getProviders
csrfToken
: Rename to getCsrfToken
signin
: Rename to signIn
signout
: Rename to signOut
Provider
: Rename to SessionProvider
3. Provider
changes.
Provider
is renamed to SessionProvider
options
prop is now flattened as the props of SessionProvider
.clientMaxAge
has been renamed to staleTime
.keepAlive
has been renamed to refetchInterval
.- <Provider options={{clientMaxAge: 0, keepAlive: 0}}>{children}</Provider>
+ <SessionProvider staleTime={0} refetchInterval={0}>{children}</SessionProvider>
4. It is now required to wrap the part of your application that uses useSession
into a SessionProvider
.
Usually, the best place for this is in your pages/_app.jsx
file:
import { SessionProvider } from "next-auth/react"
export default function App({
Component,
pageProps: { session, ...pageProps }
}) {
return (
// `session` comes from `getServerSideProps` or `getInitialProps`.
// Avoids flickering/session loading on first load.
<SessionProvider session={session}>
<Component {...pageProps} />
</SessionProvider>
)
}
Published by github-actions[bot] over 3 years ago
OAuthProviderType
(ed34534)AzureADB2C
, you will need to update it to to AzureAD
There should be no other changes needed.Published by github-actions[bot] over 3 years ago
Published by github-actions[bot] over 3 years ago
Published by github-actions[bot] over 3 years ago
Check out https://github.com/nextauthjs/adapters
The migration is super easy and has HUGE advantages for those not using TypeORM.
// [...nextauth].js
+ import TypeORMAdapter from "@next-auth/typeorm-legacy-adapter"
import NextAuth from "next-auth"
...
export default NextAuth({
- database: "yourconnectionstring",
+ adapter: TypeORMAdapter("yourconnectionstring")
})
Published by github-actions[bot] over 3 years ago
react-dom
version (#1956) (d2882f1)events
handlers' types (#1853) (ffd0601), closes #1909 #1900 #1891 #1914 #1912 #192 #1922 #1932
ctxOrReq
optional in getCsrfToken()
(#1850) (07e2a83)GetSessionOptions
optional (#1851) (fb04ab4)authorize
(#1979) (0fae0c7)