Scaffold Next.js calculator app as SPA wrapper#851
Scaffold Next.js calculator app as SPA wrapper#851SakshiKekre wants to merge 10 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
fefeb1c to
56db944
Compare
56db944 to
c4e2f20
Compare
f92aeb8 to
1b2fe01
Compare
1b2fe01 to
c9e1d53
Compare
c9e1d53 to
9372594
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…viders Swap react-router-dom imports to the abstraction layer (useAppNavigate, useAppLocation, AppLink) in shared components used by all extracted pages: StandardLayout, Sidebar, SidebarNavItem, CountrySelector, HeaderLogo, NavItem. Add CalculatorProviders + MetadataBootstrap in calculator-app for extracted Next.js routes. Update test utilities with RouterContextBridge. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
61f12f5 to
dcf2c6d
Compare
Migration gap:
|
Summary
Scaffolds a Next.js app (
calculator-app/) that wraps the existing Vite calculator as a client-side SPA, and adds router abstraction infrastructure for incremental route extraction. Follows the official Next.js Vite migration guide.SPA wrapper
[[...slug]]catch-all route importsCalculatorAppwithssr: falseimport.meta.envpolyfilled via webpack DefinePlugingenerateStaticParamsprerenders the index routeapp/src/app.cssapp/public/Router abstraction (for incremental route extraction)
CountryContext— decouplesuseCurrentCountry()from react-router'suseParamsNavigationContext—useAppNavigate()with push/replace/back, works in both routersLocationContext—useAppLocation()/useAppPathname()for pathname and searchAppLink— drop-in replacement for react-router'sLinkcomponentCountryGuard(react-router) and[countryId]/layout.tsx(Next.js)CountryProviderin test wrappersCI
pr.yamlDependent PRs and merge strategy
Merge order: leaves first, then merge up into this PR, then merge to main.
nextjs-calculator-migration)mainThis avoids rebasing each PR onto main individually. The PRs are tightly coupled (all part of the same migration, all depend on the same infra), so merging them as a single unit makes sense. Each sub-PR is reviewed individually; this PR is the integration point.
Going live checklist
Before going live
calculator-app/(separate from existingpolicyengine-calculator)NEXT_PUBLIC_WEBSITE_URL,NEXT_PUBLIC_CALCULATOR_URL,NEXT_PUBLIC_IPAPI_CO_KEYcalculator-app/,app/src/,packages/design-system/trigger rebuildsGoing live
app.policyengine.orgdomain to the new Vercel projectImmediately after going live
calculator-app/src/app/[[...slug]]/(page.tsx + client.tsx). This is dead code once all routes are extracted and removes the entire Vite bundle from the Next.js appAfter Vite decommission (later)
CalculatorRouter.tsx(ModifyReportPageRoute,ReportOutputRoute)CalculatorRouter.tsxandCalculatorApp.tsxapp/src/main.calculator.tsxapp/src/intocalculator-app/src/Multi-zones (future, independent of Vite decommission)
Once website, model explorer, and API docs are all on Next.js, enable multi-zones to share a single domain (
policyengine.org) with seamless client-side navigation. Currently these are separate Vercel projects served via rewrites, causing full page reloads when users click between Model, API, and other apps in the header. Multi-zones would eliminate that. Ref: #755Dev workflow changes
Before this PR merges
cd app && bun run dev:calculator— runs Vite calculator on port 3001After this PR merges (during migration)
cd app && bun run dev:calculator— Vite calculator still works (port 3001)cd calculator-app && bun run dev— Next.js calculator (same port, run one at a time)After going live
cd calculator-app && bun run dev— primary dev serverTest plan
cd calculator-app && bun run dev— loads full calculator at localhost:3001cd app && VITE_APP_MODE=calculator npx vite— Vite dev server still worksbun run test— all 2950 tests passbun run lint— no errorsbun run typecheck— passes