Skip to content

Migrate from Vite + React Router to Next.js #811

@MaxGhenis

Description

@MaxGhenis

Supersedes #752 (evaluation issue) and builds on the RFC in #753.

Overview

Migrate policyengine-app-v2 from Vite + React Router to Next.js App Router. The current app has two entry points (website + calculator), 25 pages, 195 blog posts, 184 components, and Vercel edge middleware.

See #752 for full rationale (SEO/LLM accessibility, edge middleware complexity, no ISR, React team recommendation, Vercel-native).

Migration strategy

Approach: Separate PRs to main with Next.js and Vite running in parallel.

Phase 1 adds a next/ folder with its own Vercel project. The existing Vite app continues working untouched. Each subsequent PR migrates routes. The final PR removes Vite.

Alternatives considered

Approach Pros Cons
Separate PRs to main (chosen) Small reviewable diffs, CI validates each step, easy to pause/reprioritize Must keep both build systems working simultaneously
Feature branch with sub-PRs Main stays stable, no parallel builds needed Branch diverges over weeks, merge conflicts accumulate, big-bang cutover
One big PR Simplest git workflow, clean cutover Unreviewable diff, all-or-nothing, blocks other work
New repo, swap Vercel Cleanest setup, no build conflicts Two repos to maintain, shared changes need syncing, lose git history

Phases

Key decisions

  • Same repo, parallel builds: Next.js in next/ folder alongside existing Vite app/
  • Blog format: Convert 195 lazy-loaded TSX articles to MDX with static generation
  • Dual app: Website and calculator migrate independently (already separate routers)

Current architecture

Component Count Migration difficulty
Static pages ~10 Easy
Blog articles 195 Medium (format conversion)
Calculator pages 6 (with nested sub-routes) Hard
Components 184 Medium (context/router refactor)
Hooks 42 Medium
Redux slices 1 (metadata) Easy
Contexts ~10 Medium
Vercel rewrites 6 Easy
Edge middleware 1 (complex) Hard

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions