router-core/code-splitting

Automate route code-splitting for TanStack Router with .lazy.tsx files.

14.9k|1.8k|Updated Jan 14, 2019
One-click install
npx skills add https://github.com/TanStack/router --skill router-core-code-splitting
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: router-core/code-splitting
Source: https://github.com/TanStack/router/tree/main/packages/router-core/skills/router-core/code-splitting
Command: npx skills add https://github.com/TanStack/router --skill router-core-code-splitting

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Automatically manage and optimize route code splitting to minimize initial bundle size while preserving fast, on-demand loading for TanStack Router apps.

Core Features & Use Cases

  • Automatic code splitting with autoCodeSplitting, ensuring critical route code loads upfront while non-critical UI files are lazy-loaded.
  • Support for .lazy.tsx, createLazyFileRoute, createLazyRoute, and getRouteApi for typed hooks in split files.
  • Per-route override with codeSplitGroupings and programmatic split behavior for fine-grained control.

Quick Start

Configure automatic code splitting in your bundler and create a sample route using .lazy.tsx to demonstrate per-route grouping.

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 reduce initial bundle size with TanStack Router code splitting?

TanStack Router code splitting reduces initial bundle size by automatically lazy-loading non-critical UI files while ensuring critical route code loads upfront. You can enable autoCodeSplitting in your bundler configuration.

What is the .lazy.tsx file convention used for in TanStack Router?

The .lazy.tsx file convention in TanStack Router is used to define lazy-loaded route components. It works with createLazyFileRoute and createLazyRoute to maintain typed hooks in split files for on-demand loading.

Can I override automatic code splitting for specific routes?

Yes, you can override automatic code splitting for specific routes using the per-route codeSplitGroupings option. This allows fine-grained, programmatic control over split behavior for individual route configurations.

How do I get typed route hooks in my split code files?

To get typed route hooks in split code files, use getRouteApi alongside createLazyFileRoute or createLazyRoute. This ensures your .lazy.tsx files maintain full TypeScript type safety during code splitting.

Does autoCodeSplitting work with React apps using TanStack Router?

Yes, autoCodeSplitting targets React apps using TanStack Router to automate route code splitting. It configures your bundler to split code automatically, minimizing initial bundle size while preserving fast on-demand loading.