Skip to content

feat: add two-phase route definition for RSC support#121

Merged
uhyo merged 1 commit intomasterfrom
feat/two-phase-route-definition
Feb 24, 2026
Merged

feat: add two-phase route definition for RSC support#121
uhyo merged 1 commit intomasterfrom
feat/two-phase-route-definition

Conversation

@uhyo
Copy link
Copy Markdown
Owner

@uhyo uhyo commented Feb 24, 2026

Summary

  • Add PartialRouteDefinition type and bindRoute() function to support splitting route definitions into Phase 1 (shared: id, path, loader) and Phase 2 (server: component binding)
  • This enables client components to import Phase 1 routes for type-safe hooks while keeping server component references server-only
  • Widen hook constraints (useRouteParams, useRouteData, useRouteState) to accept PartialRouteDefinition

Changes

  • Add partialRouteDefinitionSymbol and PartialRouteDefinition interface
  • Add 6 partial overloads each to route() and routeState()
  • Add bindRoute() function with typed/untyped overloads
  • Update type extraction utilities for both route types
  • Export bindRoute and PartialRouteDefinition from both index.ts and server.ts entry points
  • Add runtime tests for bindRoute() and comprehensive type-level tests

Test plan

  • Runtime tests for bindRoute() covering basic binding, loader preservation, and state routes
  • Type-level tests verifying all overloads, type extraction, and hook compatibility
  • Existing tests continue to pass

🤖 Generated with Claude Code

Add PartialRouteDefinition type and bindRoute() function to support
splitting route definitions into Phase 1 (shared: id, path, loader)
and Phase 2 (server: component binding). This enables client components
to import Phase 1 routes for type-safe hooks while keeping server
component references server-only.

- Add partialRouteDefinitionSymbol and PartialRouteDefinition interface
- Add 6 partial overloads each to route() and routeState()
- Add bindRoute() function with typed/untyped overloads
- Widen hook constraints to accept PartialRouteDefinition
- Update type extraction utilities for both route types
- Export bindRoute and PartialRouteDefinition from both entry points

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@uhyo uhyo merged commit 6eb71b9 into master Feb 24, 2026
1 check passed
@uhyo uhyo deleted the feat/two-phase-route-definition branch February 24, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant