How can I prevent all pages from becoming dynamic?
Unanswered
Rex posted this in #help-forum
RexOP
Here is what I am trying to acheive
the much I understand if I add hook which checks for loggedin user all the child pages will be dynamically generated.
What can be done or what am I doing wrong?
import Image from "next/image";
import Link from "next/link";
export default function Home() {
// basically hook which check for auth user
const loggedUser = false;
return (
<main className="flex flex-col items-center mt-12">
<h1 className="font-semibold text-4xl">Website</h1>
{loggedUser ? (
// will be dynamic based on user
<div>Welcome back Mubashir</div>
) : (
// should be statically generated for better speed at build time
<div className="flex gap-8">
<Link href="/login">Login</Link>
<Link href="/signup">Signup</Link>
</div>
)}
</main>
);
}the much I understand if I add hook which checks for loggedin user all the child pages will be dynamically generated.
What can be done or what am I doing wrong?
2 Replies
RexOP
I will create two components for pages but the point is i have the auth hook at the top would not it make every child component dynamically generate
RexOP
here is the proper code
I created the build and I am getting
import { createClient } from "@/utils/supabase/server";
import AuthenticatedHome from "./components/AuthenticatedHome";
import HomeWithoutAuthentication from "./components/HomeWithoutAuthentication";
export default async function Home() {
const supabase = createClient();
const { data } = await supabase?.auth?.getUser();
return (
<main className="flex flex-col items-center mt-12">
<h1 className="text-4xl font-semibold ">Website</h1>
{data?.user ? (
<AuthenticatedHome data={data} />
) : (
<HomeWithoutAuthentication />
)}
</main>
);
}I created the build and I am getting
f for this as "server rendered on demand"