Next.js Discord

Discord Forum

How to disable prerender in App Router

Unanswered
Scaly-naped Pigeon posted this in #help-forum
Open in Discord
Scaly-naped PigeonOP
I need accessToken to fetch user data
So, I want to disable this fetch at build time.
How to disable prerender?

const Update = async () => {
  const myProfile = await fetchUserProfile();

  return (
    <>
      <Header title="프로필 수정" back />
      <UpdateForm defaultValues={myProfile} />
    </>
  );
};

export default Update;

2 Replies

nextjs will not prerender parts with useEffect
so what you would do is have a stwte variable, and set it to true in a useEffect with an empty deps array.. if thhe state is true do whatever you wanna do cause that means you are rendering CSR