Next.js Discord

Discord Forum

Why my `/post` page is dynamic rendered?

Answered
M7ilan posted this in #help-forum
Open in Discord
Hello, my /post page shows that it's dynamic rendered when building time, there's nothing to dynamic it's just a post form for people to post their posts.

I used the force-static but I don't want to, I just want to know why it's dynamic rendered.
Answered by ᴉuɐpɹɐɐ
you used cookies()
View full answer

22 Replies

Here's the file src\app\(app)\post\page.tsx
// export const dynamic = "force-static";

import PostForm from "@/components/post/PostForm";

export default function page() {
  return (
    <div className="grid">
      <h1>...</h1>
      <p className="text-muted-foreground">...</p>
      <hr className="my-4" />
      <PostForm />
    </div>
  );
}
The PostForm component is big so I'll do my best explaining it is.
it's a Form that uses react-hook-form with zod, it's mostly like in [this page](https://ui.shadcn.com/docs/components/form).

There's a onSubmit function which I think it causes the dynamic rendering I think, it uses server actions to create the post and upload images in the database and finally uses next/navigation router to push the user to his post when it's created.

I have tried using the force-static and it works great but as I said I want to know the reason this happening. I also hate forcing. thank you
yup
it's private..
give me a sec I can publish it
whats your build log
try using export const dynamic = 'error'
then see what error it will print
wait, that image uses force-static
there you go
you used cookies()
Answer
hmm
I used it in a server action tho
if you call that server action in server components it is being called normally
if you call that server action in server components, it is just calling a normal function
I see
yeah, unless you call it in form actions or client components