TanStackT
TanStack8mo ago
1 reply
verbal-lime

Prerendering error

I'm currently encountering an error when trying to build my application. My application is nextJS version 15 using app router:

The error I'm getting:

Error occurred prerendering page "/test2". Read more: https://nextjs.org/docs/messages/prerender-error
Error: redacted
    at C:\Users\Desktop\Projects\Mint\mint-hjemmeside\.next\server\chunks\793.js:1:30664
Export encountered an error on /test2/page: /test2, exiting the build.
 ⨯ Next.js build worker exited with code: 1 and signal: null


My code:
export default async function page() {
    prefetch(trpc.post.hello.queryOptions({ text: "Hello" }));

    return (
        <div>
            <HydrateClient>
                <ErrorBoundary fallback={<div>Something went wrong</div>}>
                    <Suspense fallback={<div>Loading...</div>}>
                        <div>Hello!</div>
                    </Suspense>
                </ErrorBoundary>
            </HydrateClient>
        </div>
    );
}


I saw that juliusmarminge might have gotten a similar error, but I'm not sure. Its a while ago. https://github.com/TanStack/query/pull/8383#issuecomment-2593409074

Here he commented, that adding export const dynamic = "force-dynamic" fixed the error - It also fixed it for me. If it's the same error that I'm encountering, has there then a better solution, so I don't have to tell each file to be dynamic?
Was this page helpful?