Does relay-nextjs support NextJS per-page layout? #97
-
Hey. I'm facing an issue where I'm unable to create a layout for each domain in my app using relay-nextjs. Unfortunately, the layout is being ignored. Here's a snippet of my code function SigninPage({ preloadedQuery }: RelayProps<{}, viewer_viewerQuery>) {
const query = usePreloadedQuery(ViewerQuery, preloadedQuery)
console.log(query.viewer?.id)
return (
<SigninFrom />
)
}
function Loading() {
return <div>Loading...</div>;
}
SigninPage.getLayout = function getLayout(page: ReactNode) {
return <AuthLayout>{page}</AuthLayout>;
};
export default withRelay(SigninPage, ViewerQuery, {
fallback: <Loading />,
createClientEnvironment: () => getClientEnvironment()!,
serverSideProps: async (ctx) => {
const token = ctx.req?.cookies['auth'] ?? null
return { token };
},
createServerEnvironment: async (
ctx,
{ token }: { token: string | null }
) => {
const { createServerEnvironment } = await import('@/lib/server/relay_server_environment');
return createServerEnvironment(token);
},
}); |
Beta Was this translation helpful? Give feedback.
Answered by
sahidrahman404
Oct 9, 2023
Replies: 1 comment 3 replies
-
@sahidrahman404 This library does not support the app router at all, only the pages router. The app router does not support server rendering components using Relay hooks which is a fundamental requirement for Revere. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oops, sorry for the confusion. To get the layout working correctly, I realized that I need to assign the
getLayout()
method to the return value of thewithRelay()
function.