Skip to content

Migrate from Next.js to TanStack Start#49

Closed
nwthomas wants to merge 5 commits into
mainfrom
cursor/tanstack-start-migration-4a18
Closed

Migrate from Next.js to TanStack Start#49
nwthomas wants to merge 5 commits into
mainfrom
cursor/tanstack-start-migration-4a18

Conversation

@nwthomas
Copy link
Copy Markdown
Owner

@nwthomas nwthomas commented May 9, 2026

Summary

TanStack Start migration (Vite + Nitro + TanStack Router) preserving visuals, OG images, and MDX blog content.

Latest fix (503 on Vercel)

Cause: src/utils/redis.ts called RedisSingleton.getInstance() at module load time. That threw when REDIS_URL / REDIS_TOKEN were unset (e.g. preview deployments), crashing the serverless bundle during cold start → 503.

Change: Export getRedis() instead of a singleton redis export. It returns null when Redis env vars are missing—no throw on import. Routes:

  • POST /views: Returns 204 if Redis is unavailable (graceful no-op).
  • Writing loader / OG image: Skips view counts when Redis is unavailable.

Production with Redis configured behaves as before.

Earlier Vercel fix

508 INFINITE_LOOP_DETECTED: Nitro vercel preset + TanStack Start prerender: { enabled: false } when VERCEL is set.

Open in Web Open in Cursor 

Replace Next.js App Router with TanStack Start (Vite, TanStack Router, Nitro).
Move application code under src/ with file routes in src/routes/, MDX in src/content,
and Redux/theme shell preserved.

Post routes use MDXProvider with the same writing components; next/image is replaced
with native img for parity. Open Graph routes use @vercel/og ImageResponse. Redis-backed
views and Atom feeds are implemented as server route handlers. ESLint targets src and
config only; client Sentry uses VITE_SENTRY_DSN when set.

Co-authored-by: Nathan Thomas <nwthomas@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
personal-portfolio Ready Ready Preview, Comment May 19, 2026 10:47pm

Co-authored-by: Nathan Thomas <nwthomas@users.noreply.github.com>
- Add vercel.json: bun install/build and framework null (avoid Next defaults)
- Pin packageManager and align @eslint/js with eslint 9
- Set Nitro preset to vercel when VERCEL is set (correct .vercel/output)
- Document Vercel vs local start in AGENTS.md

Co-authored-by: Nathan Thomas <nwthomas@users.noreply.github.com>
Nitro 3.0.0 Vercel preset lacked fetchViteEnv bridging; SSR fell through to
global fetch and re-invoked the same serverless function (508).

Upgrade to nitro@3.0.260311-beta so globalThis.__nitro_vite_envs__ and
fetchViteEnv('ssr') dispatch internally (nitro#4011).

- Use top-level nitro({ preset: 'vercel' }) for plugin API in beta
- Explicitly disable TanStack Start prerender on Vercel preset builds
- Document in AGENTS.md

Co-authored-by: Nathan Thomas <nwthomas@users.noreply.github.com>
@nwthomas nwthomas marked this pull request as ready for review May 9, 2026 17:17
Replace eager RedisSingleton.getInstance() with getRedis() that returns null
when REDIS_URL/REDIS_TOKEN are unset. Server routes and OG image handlers no
longer throw during module load on Vercel previews, which was causing 503s.

POST /views returns 204 when Redis is unavailable; writing loader skips mGet;
OG images omit view counts when Redis is absent.

Co-authored-by: Nathan Thomas <nwthomas@users.noreply.github.com>
@nwthomas nwthomas closed this May 23, 2026
@nwthomas nwthomas deleted the cursor/tanstack-start-migration-4a18 branch May 23, 2026 18:58
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