Nextjs 14 Next-auth SessionProvider
Answered
Yellowstripe scad posted this in #help-forum
Yellowstripe scadOP
where do I put the sessionProvider and how do I set it up?
i'm getting this error:
i'm getting this error:
Error: [next-auth]: `useSession` must be wrapped in a <SessionProvider />Answered by Chilean jack mackerel
create
and wrap children content in layout file with it.
NextAuthProvider.tsx file like this:"use client";
import { SessionProvider } from "next-auth/react";
type Props = {
children?: React.ReactNode;
};
export const NextAuthProvider = ({ children }: Props) => {
return (
<SessionProvider>
{children}
</SessionProvider>
)
};and wrap children content in layout file with it.
2 Replies
Chilean jack mackerel
create
and wrap children content in layout file with it.
NextAuthProvider.tsx file like this:"use client";
import { SessionProvider } from "next-auth/react";
type Props = {
children?: React.ReactNode;
};
export const NextAuthProvider = ({ children }: Props) => {
return (
<SessionProvider>
{children}
</SessionProvider>
)
};and wrap children content in layout file with it.
Answer
@Chilean jack mackerel create `NextAuthProvider.tsx` file like this:
ts
"use client";
import { SessionProvider } from "next-auth/react";
type Props = {
children?: React.ReactNode;
};
export const NextAuthProvider = ({ children }: Props) => {
return (
<SessionProvider>
{children}
</SessionProvider>
)
};
and wrap children content in layout file with it.
Yellowstripe scadOP
you're a lifesaver, I knew I had to do something like this but I was unsure of what to put in the file. Thanks!!!