router-core/code-splitting

Installation
SKILL.md

Code Splitting

TanStack Router separates route code into critical (required to match and start loading) and non-critical (can be lazy-loaded). The bundler plugin can split automatically, or you can split manually with .lazy.tsx files.

CRITICAL: Never export component functions from route files — exported functions are included in the main bundle and bypass code splitting entirely.

CRITICAL: Use getRouteApi('/path') in code-split files, NOT import { Route } from './route'. Importing Route defeats code splitting.

What Stays in the Main Bundle (Critical)

  • Path parsing/serialization
  • validateSearch
  • loader, beforeLoad
  • Route context, static data
  • Links, scripts, styles

What Gets Split (Non-Critical)

Installs
GitHub Stars
16
First Seen
router-core/code-splitting — lightfastai/lightfast