Skip to content

Commit cb7c1c0

Browse files
committed
add more skills for router
1 parent c30d852 commit cb7c1c0

8 files changed

Lines changed: 194 additions & 2 deletions

File tree

packages/router-skills/manifest.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,28 @@
88
"skills/v1/error-boundaries.md",
99
"skills/v1/file-based-routing.md",
1010
"skills/v1/index.md",
11+
"skills/v1/invalidation.md",
1112
"skills/v1/layouts.md",
1213
"skills/v1/links.md",
1314
"skills/v1/loaders.md",
15+
"skills/v1/navigate-options.md",
1416
"skills/v1/navigation.md",
1517
"skills/v1/not-found-boundaries.md",
1618
"skills/v1/params.md",
19+
"skills/v1/pending-ui.md",
1720
"skills/v1/prefetching.md",
21+
"skills/v1/redirects.md",
1822
"skills/v1/route-context.md",
1923
"skills/v1/route-ids.md",
24+
"skills/v1/route-masking.md",
2025
"skills/v1/route-trees.md",
26+
"skills/v1/router-provider.md",
2127
"skills/v1/router-state.md",
2228
"skills/v1/search-defaults.md",
2329
"skills/v1/search-validation.md",
24-
"skills/v1/ssr-loaders.md"
30+
"skills/v1/ssr-loaders.md",
31+
"skills/v1/use-match.md",
32+
"skills/v1/use-search.md"
2533
]
2634
}
2735
}

packages/router-skills/skills/topics.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,12 @@
1616
"navigation.md",
1717
"router-state.md",
1818
"ssr-loaders.md",
19-
"ssr-loaders.md"
19+
"use-match.md",
20+
"use-search.md",
21+
"redirects.md",
22+
"route-masking.md",
23+
"router-provider.md",
24+
"pending-ui.md",
25+
"invalidation.md",
26+
"navigate-options.md"
2027
]

packages/router-skills/skills/v1/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ How to pick a skill:
3838
- Navigating programmatically after a submit or action -> `@skills/router/navigation`
3939
- Showing pending UI or transition state -> `@skills/router/router-state`
4040
- Ensuring loader data is serializable for SSR -> `@skills/router/ssr-loaders`
41+
- Reading a route match or match metadata -> `@skills/router/use-match`
42+
- Reading validated search params -> `@skills/router/use-search`
43+
- Redirecting from loaders/actions -> `@skills/router/redirects`
44+
- Presenting friendly URLs for internal routes -> `@skills/router/route-masking`
45+
- Wiring the router into your app root -> `@skills/router/router-provider`
46+
- Showing pending UI during navigation -> `@skills/router/pending-ui`
47+
- Revalidating data after mutations -> `@skills/router/invalidation`
48+
- Using replace/state/hash when navigating -> `@skills/router/navigate-options`
4149

4250
Next:
4351

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
id: redirects
3+
title: Redirects
4+
versions:
5+
- latest
6+
- ">=1 <2"
7+
summary: Redirect from loaders or actions.
8+
resources:
9+
- https://tanstack.com/router/latest/docs/guide/redirects
10+
- https://tanstack.com/router/latest/docs/api/router/redirect
11+
---
12+
13+
# Redirects
14+
15+
Purpose:
16+
17+
- Redirect from loaders or actions.
18+
19+
Scope:
20+
21+
- Use when gating routes or handling auth flows.
22+
23+
Guidelines:
24+
25+
- Redirect early in loaders to avoid flashes.
26+
- Preserve intent with `search` or `hash`.
27+
- Avoid redirect loops.
28+
29+
Example:
30+
31+
```ts
32+
throw redirect({ to: "/login" })
33+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
id: route-masking
3+
title: Route Masking
4+
versions:
5+
- latest
6+
- ">=1 <2"
7+
summary: Present friendly URLs without changing route structure.
8+
resources:
9+
- https://tanstack.com/router/latest/docs/guide/route-masking
10+
---
11+
12+
# Route Masking
13+
14+
Purpose:
15+
16+
- Present friendly URLs without changing route structure.
17+
18+
Scope:
19+
20+
- Use when exposing public paths for internal routes.
21+
22+
Guidelines:
23+
24+
- Define masks for user-friendly URLs.
25+
- Keep masks aligned with params and search.
26+
- Document masks to avoid confusion.
27+
28+
Example:
29+
30+
```ts
31+
const route = createRoute({
32+
getParentRoute: () => rootRoute,
33+
path: "projects/$projectId",
34+
mask: "/p/$projectId",
35+
})
36+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
id: router-provider
3+
title: Router Provider
4+
versions:
5+
- latest
6+
- ">=1 <2"
7+
summary: Register the router with your app entrypoint.
8+
resources:
9+
- https://tanstack.com/router/latest/docs/guide/installation
10+
- https://tanstack.com/router/latest/docs/api/router/router-provider
11+
---
12+
13+
# Router Provider
14+
15+
Purpose:
16+
17+
- Register the router with your app entrypoint.
18+
19+
Scope:
20+
21+
- Use when wiring the router into React, Solid, or Vue roots.
22+
23+
Guidelines:
24+
25+
- Create the router once at startup.
26+
- Provide route context dependencies at creation.
27+
- Keep provider near the root layout.
28+
29+
Example:
30+
31+
```tsx
32+
const router = createRouter({ routeTree })
33+
<RouterProvider router={router} />
34+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
id: use-match
3+
title: useMatch
4+
versions:
5+
- latest
6+
- ">=1 <2"
7+
summary: Read the active route match and its params.
8+
resources:
9+
- https://tanstack.com/router/latest/docs/guide/matching
10+
- https://tanstack.com/router/latest/docs/api/router/use-match
11+
---
12+
13+
# useMatch
14+
15+
Purpose:
16+
17+
- Read the active route match and params.
18+
19+
Scope:
20+
21+
- Use when you need route metadata for the current match.
22+
23+
Guidelines:
24+
25+
- Match by route ID or path.
26+
- Use matches to derive UI state.
27+
- Avoid matching inside render loops.
28+
29+
Example:
30+
31+
```ts
32+
const match = useMatch({ from: "projects/$projectId" })
33+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
id: use-search
3+
title: useSearch
4+
versions:
5+
- latest
6+
- ">=1 <2"
7+
summary: Read typed search params for a route.
8+
resources:
9+
- https://tanstack.com/router/latest/docs/guide/search-params
10+
- https://tanstack.com/router/latest/docs/api/router/use-search
11+
---
12+
13+
# useSearch
14+
15+
Purpose:
16+
17+
- Read typed search params for a route.
18+
19+
Scope:
20+
21+
- Use when consuming validated search state.
22+
23+
Guidelines:
24+
25+
- Pair with `validateSearch` schemas.
26+
- Prefer route-scoped search reads.
27+
- Keep search state serializable.
28+
29+
Example:
30+
31+
```ts
32+
const search = route.useSearch()
33+
```

0 commit comments

Comments
 (0)