Skip to content

Commit 551e649

Browse files
authored
Merge branch 'main' into test-2255
2 parents dbd7a8e + e30d59a commit 551e649

File tree

800 files changed

+15771
-3001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

800 files changed

+15771
-3001
lines changed

.github/renovate.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@types/node",
2121
"@types/react",
2222
"@types/react-dom",
23+
"h3",
2324
"node",
2425
"react",
2526
"react-dom",

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ ts-perf
5555
.netlify
5656

5757
nx-cloud.env
58-
.vscode
5958
.nx/cache
6059
.nx/workspace-data
6160

@@ -74,3 +73,7 @@ app.config.js.timestamp_*
7473
app.config.ts.timestamp_*
7574
.idea
7675
*.vitest-temp.json
76+
77+
# Handling VSCode settings
78+
/.vscode/
79+
!/examples/react/**/.vscode/settings.json

docs/router/framework/react/api/router/useParamsHook.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ The `useParams` hook accepts an optional `options` object.
1515
- Optional - `default: true`
1616
- If `false`, the `opts.from` option will be ignored and types will be loosened to `Partial<AllParams>` to reflect the shared types of all params.
1717

18+
### `opts.shouldThrow` option
19+
20+
- Type: `boolean`
21+
- Optional
22+
- `default: true`
23+
- If `false`,`useParams` will not throw an invariant exception in case a match was not found in the currently rendered matches; in this case, it will return `undefined`.
24+
1825
### `opts.select` option
1926

2027
- Optional

docs/router/framework/react/api/router/useSearchHook.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ The `useSearch` hook accepts an `options` object.
1515
- Required
1616
- The RouteID to match the search query parameters from.
1717

18+
### `opts.shouldThrow` option
19+
20+
- Type: `boolean`
21+
- Optional
22+
- `default: true`
23+
- If `false`,`useSearch` will not throw an invariant exception in case a match was not found in the currently rendered matches; in this case, it will return `undefined`.
24+
1825
### `opts.select` option
1926

2027
- Type: `(search: SelectedSearchSchema) => TSelected`

docs/router/framework/react/guide/custom-search-param-serialization.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ So, if we were to turn the previous object into a search string using this confi
9292
?page=1&sort=asc&filters=eyJhdXRob3IiOiJ0YW5uZXIiLCJtaW5fd29yZHMiOjgwMH0%3D
9393
```
9494

95+
> [!WARNING]
96+
> If you are serializing user input into Base64, you run the risk of causing a collision with the URL deserialization. This can lead to unexpected behavior, such as the URL not being parsed correctly or being interpreted as a different value. To avoid this, you should encode the search params using a safe binary encoding/decoding method (see below).
97+
9598
## Using the query-string library
9699

97100
The [query-string](https://github.com/sindresorhus/query-string) library is a popular for being able to reliably parse and stringify query strings. You can use it to customize the serialization format of your search params. This can be done with the following code:

docs/router/framework/react/guide/file-based-routing.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,16 +358,27 @@ Here are some resources to help you ignore the generated route tree file:
358358
- ESLint - [https://eslint.org/docs/latest/use/configure/ignore#ignoring-files](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files)
359359
- Biome - [https://biomejs.dev/reference/configuration/#filesignore](https://biomejs.dev/reference/configuration/#filesignore)
360360

361-
If you are using VSCode, you can also add the following to your `.vscode/settings.json` file to exclude the generated route tree file from the editor's file watcher:
361+
> [!WARNING]
362+
> If you are using VSCode, you may experience the route tree file unexpectedly open (with errors) after renaming a route.
363+
364+
You can prevent that from the VSCode settings by marking the file as readonly. Our recommendation is to also exclude it from search results and file watcher with the following settings:
362365

363366
```json
364367
{
368+
"files.readonlyInclude": {
369+
"**/routeTree.gen.ts": true
370+
},
365371
"files.watcherExclude": {
366372
"**/routeTree.gen.ts": true
373+
},
374+
"search.exclude": {
375+
"**/routeTree.gen.ts": true
367376
}
368377
}
369378
```
370379

380+
You can use those settings either at a user level or only for a single workspace by creating the file `.vscode/settings.json` at the root of your project.
381+
371382
## Configuration
372383

373384
File-based routing comes with some sane defaults that should work for most projects:

docs/router/framework/react/guide/scroll-restoration.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ title: Scroll Restoration
77

88
Out of the box, TanStack Router supports both **hash scrolling** and **top-of-page scrolling** without any additional configuration.
99

10+
## Scroll-to-top & Nested Scrollable Areas
11+
12+
By default, scroll-top-top mimics the behavior of the browser, which means only the `window` itself is scrolled to the top after successful navigation. For many apps however, it's common for the main scrollable area to be a nested div or similar because of advanced layouts. If you would like TanStack Router to also scroll these main scrollable areas for you, you can add selectors to target them using the `routerOptions.scrollToTopSelectors`:
13+
14+
```tsx
15+
const router = createRouter({
16+
scrollToTopSelectors: ['#main-scrollable-area'],
17+
})
18+
```
19+
20+
These selectors are handled **in addition to `window`** which cannot be disabled currently.
21+
1022
## Scroll Restoration
1123

1224
Scroll restoration is the process of restoring the scroll position of a page when the user navigates back to it. This is normally a built-in feature for standard HTML based websites, but can be difficult to replicate for SPA applications because:

docs/router/framework/react/quick-start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bun create @tanstack/router
2222
deno init --npm @tanstack/router
2323
```
2424

25-
Follow the prompts to setup the a fully setup TanStack Router project.
25+
Follow the prompts to scaffold a full TanStack Router project.
2626

2727
### Manual Setup
2828

@@ -65,7 +65,7 @@ export default defineConfig({
6565
```
6666

6767
> [!TIP]
68-
> If you are not using Vite, or any supported bundler, you can check out the [TanStack Router CLI](./guide/file-based-routing.md#configuration-with-the-tanstack-router-cli) guide for more info.
68+
> If you are not using Vite, or any of the supported bundlers, you can check out the [TanStack Router CLI](./guide/file-based-routing.md#configuration-with-the-tanstack-router-cli) guide for more info.
6969
7070
Create the following files:
7171

e2e/react-router/basic-esbuild-file-based/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
"@tanstack/router-e2e-utils": "workspace:^",
2525
"@types/react": "^18.2.47",
2626
"@types/react-dom": "^18.2.18",
27-
"esbuild": "^0.24.2"
27+
"esbuild": "^0.25.0"
2828
}
2929
}

e2e/react-router/basic-file-based-code-splitting/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
"@types/react": "^18.2.47",
2828
"@types/react-dom": "^18.2.18",
2929
"@vitejs/plugin-react": "^4.3.4",
30-
"vite": "^6.0.11"
30+
"vite": "^6.1.0"
3131
}
3232
}

0 commit comments

Comments
 (0)