router-core/code-splitting

Implement automatic and manual code-splitting for TanStack Router routes.

4|1|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/lespaceman/athena-workflow-marketplace --skill router-core-code-splitting-lespaceman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: router-core/code-splitting
Source: https://github.com/lespaceman/athena-workflow-marketplace/tree/main/plugins/tanstack-start/skills/upstream/%40tanstack/router-core/skills/router-core/code-splitting
Command: npx skills add https://github.com/lespaceman/athena-workflow-marketplace --skill router-core-code-splitting-lespaceman

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Optimize TanStack Router route loading by implementing automatic and manual code-splitting, enabling critical vs non-critical chunking to improve initial load performance.

Core Features & Use Cases

  • Automatic code splitting with autoCodeSplitting: true to automatically split route files into chunks.
  • Manual splitting with .lazy.tsx to control which parts are loaded lazily.
  • Per-route codeSplitGroupings and getRouteApi usage to access typed hooks in split files.
  • Support for virtual routes and code-based splitting strategies (createLazyRoute, createLazyFileRoute).
  • Global configuration options and precedence order to tailor bundling behavior.

Quick Start

Enable automatic code splitting in your bundler (autoCodeSplitting: true) and structure routes with createFileRoute using loader and component, or opt into manual splitting with .lazy.tsx for finer control.

Frequently Asked Questions about router-core/code-splitting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement code-splitting in TanStack Router?

To implement code-splitting in TanStack Router, enable automatic code splitting with autoCodeSplitting: true or use manual .lazy.tsx files to control lazy loading. This partitions routes into critical and non-critical chunks, optimizing initial load performance.

What is the difference between automatic and manual code splitting in TanStack Router?

Automatic code splitting uses autoCodeSplitting: true to automatically chunk route files, while manual splitting uses .lazy.tsx files for finer control. Both strategies support createFileRoute conventions and optimize route loading by separating critical components.

How do I access typed hooks in split route files with TanStack Router?

To access typed hooks in split route files, use getRouteApi with per-route codeSplitGroupings. This maintains type safety across lazy-loaded boundaries while allowing critical and non-critical chunks to load independently.

Does TanStack Router support splitting route loaders separately from components?

Yes, TanStack Router supports splitting route loaders separately from components. Using createFileRoute with loader and component properties, you can control which parts load lazily and which remain critical for initial rendering.

Can I use virtual routes for code-based splitting in TanStack Router?

Yes, virtual routes are supported for code-based splitting strategies using createLazyRoute and createLazyFileRoute. These allow flexible lazy loading configurations alongside global bundler options and precedence rules.

What bundler configuration is needed for TanStack Router code splitting?

Bundler configuration requires enabling autoCodeSplitting: true for automatic splitting or setting up manual .lazy.tsx conventions. Global configuration options and precedence rules tailor bundling behavior for critical vs non-critical chunk groupings.