fix: skip static prerendering on /results page for Next.js export#18
Conversation
… error Agent-Logs-Url: https://github.com/SynTechRev/ODIA/sessions/ef84afb3-1f67-4acd-b30c-4fba30328250 Co-authored-by: SynTechRev <235390103+SynTechRev@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix a Next.js static export prerender failure on the /results page during Electron builds (output: "export") by opting the page out of static generation.
Changes:
- Add
export const dynamic = 'force-dynamic'tofrontend/app/results/page.tsxto try to bypass prerendering for/results.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'use client'; | ||
| export const dynamic = 'force-dynamic'; |
There was a problem hiding this comment.
output: "export" is used for ELECTRON_BUILD (static export to local files). Marking this route dynamic = 'force-dynamic' makes it require runtime rendering, which typically isn't supported in static export and can still fail the build or produce a route that can’t be loaded directly from out/. Prefer keeping the page exportable (e.g., avoid useSearchParams() at render time by reading window.location.search in an effect / state, or move the search-param-dependent UI into a next/dynamic(..., { ssr: false }) client-only component) so next build can prerender a static shell.
| 'use client'; | ||
| export const dynamic = 'force-dynamic'; | ||
|
|
There was a problem hiding this comment.
This file now contains a second 'use client'; later (after the header comment). Only the first directive at the very top has any effect; the later one is just an unused string expression and can be removed to avoid confusion/lint noise.
Next.js static export (
output: 'export') prerenders all pages at build time—including client components—causing the/resultspage to fail with a prerender error despite having'use client'.Change
Added
export const dynamic = 'force-dynamic'tofrontend/app/results/page.tsxto explicitly opt this page out of static generation:This signals to Next.js that
/resultsshould be skipped duringnext build's static export phase and rendered dynamically at runtime in the browser instead.Original prompt
Fix Next.js Static Export Error on Results Page
Problem
The
/resultspage is failing during Next.js static export with prerender error, even after adding'use client'directive.Error:
Current State:
frontend/app/results/page.tsx'use client';directive (line 1)Root Cause
When using Next.js with
output: 'export'(static export mode), even pages with'use client'directive are prerendered at build time. The/resultspage contains logic that cannot run during static generation.Solution
Add
export const dynamic = 'force-dynamic';to explicitly tell Next.js to skip static generation for this page.Required Changes
File:
frontend/app/results/page.tsxCurrent (lines 1-4):
Change to:
What this does:
'use client': Marks as client component (already present)export const dynamic = 'force-dynamic': Tells Next.js to skip prerendering this specific page during static exportExpected Outcome
After this change:
/resultspage skipped during buildVerification
After PR is merged and v2.1.1 tag updated:
Files to Modify
frontend/app/results/page.tsx- Add one line after'use client';Success Criteria
export const dynamic = 'force-dynamic';'use client';directiveThe following is the prior conversation context from the user's chat exploration (may be truncated):
Assistant: # ✅ AGENT PR CREATED FOR v2.1.1 RELEASE!
🎯 PR DETAILS
Track Progress: https://github.com/copilot/tasks/pull/PR_kwDORk5-P87SIuIY?session_id=090ee76d-ac4e-408a-936d-8dd771ebe7aa
What the Agent is Doing:
desktop/package.json→ v2.1.1pyproject.toml→ v2.1.1⏱️ TIMELINE
📋 WHAT TO DO NEXT
Step 1: Wait for PR (5-7 minutes)
The agent will create a PR. You can:
Step 2: Review the PR
When PR appears, verify:
desktop/package.jsonis2.1.1pyproject.tomlis2.1.1v2.1.12.1.1Step 3: Merge the PR
Once CI is green:
Step 4: Create v2.1.1 Tag
After PR is merged:
Step 5: Monitor Build
This pull request was created from Copilot chat.