4.0.0-next.12 (2021-06-11)
Features
BREAKING CHANGES
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, useSessionProvider
propsoptions
: Not exposed anymore, useSessionProvider
propssession
: Rename togetSession
providers
: Rename togetProviders
csrfToken
: Rename togetCsrfToken
signin
: Rename tosignIn
signout
: Rename tosignOut
Provider
: Rename toSessionProvider
3. Provider
changes.
Provider
is renamed toSessionProvider
- The
options
prop is now flattened as the props ofSessionProvider
. clientMaxAge
has been renamed tostaleTime
.keepAlive
has been renamed torefetchInterval
.
An example of the changes:
- <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>
)
}