Skip to content

Migrate experiment app from Next.js to TanStack Start#369

Open
kcarnold wants to merge 1 commit into
mainfrom
claude/migrate-tanstack-start-OyVeQ
Open

Migrate experiment app from Next.js to TanStack Start#369
kcarnold wants to merge 1 commit into
mainfrom
claude/migrate-tanstack-start-OyVeQ

Conversation

@kcarnold

Copy link
Copy Markdown
Contributor

Summary

Migrates the experiment application from Next.js 15 (App Router) to TanStack Start, a full-stack framework built on Vite and TanStack Router. This change modernizes the build tooling and routing infrastructure while maintaining all existing functionality.

Key Changes

Framework Migration

  • Replaced Next.js with TanStack Start (Vite + TanStack Router)
  • Converted all API routes from Next.js route.ts handlers to TanStack Router file routes
  • Migrated pages from Next.js file-based routing to TanStack Router route definitions
  • Removed Next.js-specific configuration (next.config.ts, layout.tsx)

API Routes

  • app/api/chat/route.tsapp/api/chat.ts (TanStack Router file route)
  • app/api/writing-support/route.tsapp/api/writing-support.ts (TanStack Router file route)
  • app/api/log/route.tsapp/api/log.ts (TanStack Router file route)
  • Updated all handlers to use TanStack Router's createFileRoute API with server.handlers.POST

Pages & Routing

  • app/page.tsxapp/index.tsx (TanStack Router convention)
  • app/study.tsx converted to TanStack Router file route with createFileRoute('/study')
  • Created app/__root.tsx as root layout using TanStack Router's createRootRoute
  • Removed 'use client' directives (no longer needed with TanStack Start)
  • Replaced useSearchParams() from Next.js with custom useSearchParams() hook that reads from TanStack Router state

Build Configuration

  • Replaced next.config.ts with vite.config.ts
  • Updated tsconfig.json to remove Next.js-specific plugins and settings
  • Removed postcss.config.mjs (Tailwind CSS now configured via Vite plugin)
  • Updated package.json scripts: next devvite dev, next buildvite build
  • Added "type": "module" to package.json for ES modules

Dependencies

  • Removed: next, eslint-config-next, @tailwindcss/postcss, babel-plugin-react-compiler
  • Added: @tanstack/react-router, @tanstack/react-start, @tailwindcss/vite, vite, @vitejs/plugin-react
  • Updated ESLint config to use typescript-eslint and eslint-plugin-react-hooks instead of Next.js presets

Docker & Deployment

  • Updated Dockerfile to use TanStack Start build output (.output instead of .next/standalone)
  • Changed runtime user from nextjs to appuser
  • Updated environment variable from NEXT_PUBLIC_GIT_COMMIT to VITE_GIT_COMMIT

Component Updates

  • Removed 'use client' directives from all components (TanStack Start handles this automatically)
  • Updated imports in study components to use custom useSearchParams() hook instead of Next.js version

Notable Implementation Details

  • Created lib/useSearchParams.ts as a compatibility layer to provide URLSearchParams interface using TanStack Router's state
  • Created router.tsx to instantiate the TanStack Router with the generated route tree
  • All API handlers now use TanStack Router's createFileRoute with server-side handlers
  • Maintained all existing functionality and study logic without behavioral changes

https://claude.ai/code/session_011KRUvKDJnfX84QEViftUZ9

Replace Next.js 15 (App Router) with TanStack Start powered by Vite 7
and TanStack Router. Key changes:

- Routes: layout.tsx → __root.tsx, page.tsx → index.tsx, study/page.tsx → study.tsx
- API routes: Use createFileRoute with server.handlers instead of Next.js route handlers
- Config: next.config.ts + postcss.config.mjs → vite.config.ts with @tailwindcss/vite
- Imports: Replace next/navigation useSearchParams with custom hook using TanStack Router
- Remove all 'use client' directives (not needed without RSC)
- Update env vars from NEXT_PUBLIC_ prefix to VITE_ prefix
- Update Dockerfile, ESLint config, tsconfig, and .gitignore

TypeScript passes, all 20 tests pass, build succeeds.

https://claude.ai/code/session_011KRUvKDJnfX84QEViftUZ9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants