Migrate from Next.js to TanStack Start#49
Closed
nwthomas wants to merge 5 commits into
Closed
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tscalledRedisSingleton.getInstance()at module load time. That threw whenREDIS_URL/REDIS_TOKENwere unset (e.g. preview deployments), crashing the serverless bundle during cold start → 503.Change: Export
getRedis()instead of a singletonredisexport. It returnsnullwhen Redis env vars are missing—no throw on import. Routes:/views: Returns204if Redis is unavailable (graceful no-op).Production with Redis configured behaves as before.
Earlier Vercel fix
508
INFINITE_LOOP_DETECTED: Nitrovercelpreset + TanStack Startprerender: { enabled: false }whenVERCELis set.