Other

TanStack Start + .NET: type-safe routes with no Node.js server

ServiceStack Blog demis@servicestack.com (Demis)
Other

ServiceStack v10.5 ships a TanStack Start React template where the route tree is generated from files, so a link to a missing page fails the build, pages are prerendered at build time, and only your .NET app runs in production.

Key points

  • Files under `src/routes/` become routes via `createFileRoute()`; `vp dev` and `vp build` generate the typed route tree.
  • A `<Link to>` path that doesn't exist, a missing path param and search params are all checked at compile time.
  • The `tanstackStart()` Vite plugin crawls links from the home page with `crawlLinks` and prerenders each page to static HTML.
  • Routes that aren't prerendered fall back to a generated `_shell.html` page via `spa.maskPath`.
  • `createServerFn`, server routes and middleware are off-limits; ServiceStack APIs are called from the browser with the typed `JsonServiceClient`.
  • Paths served by .NET such as `/api`, `/ui`, `/admin-ui` and `/Identity` are skipped by the prerender filter, and no Node.js server is deployed.
  • The constraints live in the template's `AGENTS.md` and are checked with `npm run check`.

Real-world use

  • A React + .NET app that wants a renamed page to break the build instead of shipping a 404
  • Sites with dynamic routes like `/posts/$id` whose ids aren't known when the build runs
  • Teams that don't want to deploy, patch and secure a separate Node.js server in production
  • Apps that want prerendered HTML for fast first loads and SEO while still navigating as a SPA

This summary was generated by the agent from the original post on ServiceStack Blog. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message