@tanstack/react-router 1.132.45 → 1.133.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/llms/rules/guide.d.ts +1 -1
- package/dist/llms/rules/guide.js +9 -4
- package/dist/llms/rules/routing.d.ts +1 -1
- package/dist/llms/rules/routing.js +5 -444
- package/dist/llms/rules/setup-and-architecture.d.ts +1 -1
- package/dist/llms/rules/setup-and-architecture.js +835 -218
- package/package.json +22 -4
|
@@ -543,16 +543,16 @@ To enable file-based routing, you'll need to be using React with a supported bun
|
|
|
543
543
|
|
|
544
544
|
[//]: # 'SupportedBundlersList'
|
|
545
545
|
|
|
546
|
-
- [Installation with Vite](
|
|
547
|
-
- [Installation with Rspack/Rsbuild](
|
|
548
|
-
- [Installation with Webpack](
|
|
549
|
-
- [Installation with Esbuild](
|
|
546
|
+
- [Installation with Vite](../../installation/with-vite)
|
|
547
|
+
- [Installation with Rspack/Rsbuild](../../installation/with-rspack)
|
|
548
|
+
- [Installation with Webpack](../../installation/with-webpack)
|
|
549
|
+
- [Installation with Esbuild](../../installation/with-esbuild)
|
|
550
550
|
|
|
551
551
|
[//]: # 'SupportedBundlersList'
|
|
552
552
|
|
|
553
553
|
When using TanStack Router's file-based routing through one of the supported bundlers, our plugin will **automatically generate your route configuration through your bundler's dev and build processes**. It is the easiest way to use TanStack Router's route generation features.
|
|
554
554
|
|
|
555
|
-
If your bundler is not yet supported, you can reach out to us on Discord or GitHub to let us know.
|
|
555
|
+
If your bundler is not yet supported, you can reach out to us on Discord or GitHub to let us know.
|
|
556
556
|
|
|
557
557
|
# File Naming Conventions
|
|
558
558
|
|
|
@@ -596,445 +596,6 @@ Pathless routes wrap child routes with either logic or a component without requi
|
|
|
596
596
|
|
|
597
597
|
To learn more about pathless routes, see the [Routing Concepts - Pathless Routes](../routing-concepts.md#pathless-layout-routes) guide.
|
|
598
598
|
|
|
599
|
-
# Installation with Esbuild
|
|
600
|
-
|
|
601
|
-
[//]: # 'BundlerConfiguration'
|
|
602
|
-
|
|
603
|
-
To use file-based routing with **Esbuild**, you'll need to install the \`@tanstack/router-plugin\` package.
|
|
604
|
-
|
|
605
|
-
\`\`\`sh
|
|
606
|
-
npm install -D @tanstack/router-plugin
|
|
607
|
-
\`\`\`
|
|
608
|
-
|
|
609
|
-
Once installed, you'll need to add the plugin to your configuration.
|
|
610
|
-
|
|
611
|
-
\`\`\`tsx
|
|
612
|
-
// esbuild.config.js
|
|
613
|
-
import { tanstackRouter } from '@tanstack/router-plugin/esbuild'
|
|
614
|
-
|
|
615
|
-
export default {
|
|
616
|
-
// ...
|
|
617
|
-
plugins: [
|
|
618
|
-
tanstackRouter({
|
|
619
|
-
target: 'react',
|
|
620
|
-
autoCodeSplitting: true,
|
|
621
|
-
}),
|
|
622
|
-
],
|
|
623
|
-
}
|
|
624
|
-
\`\`\`
|
|
625
|
-
|
|
626
|
-
Or, you can clone our [Quickstart Esbuild example](https://github.com/TanStack/router/tree/main/examples/react/quickstart-esbuild-file-based) and get started.
|
|
627
|
-
|
|
628
|
-
Now that you've added the plugin to your Esbuild configuration, you're all set to start using file-based routing with TanStack Router.
|
|
629
|
-
|
|
630
|
-
[//]: # 'BundlerConfiguration'
|
|
631
|
-
|
|
632
|
-
## Ignoring the generated route tree file
|
|
633
|
-
|
|
634
|
-
If your project is configured to use a linter and/or formatter, you may want to ignore the generated route tree file. This file is managed by TanStack Router and therefore shouldn't be changed by your linter or formatter.
|
|
635
|
-
|
|
636
|
-
Here are some resources to help you ignore the generated route tree file:
|
|
637
|
-
|
|
638
|
-
- Prettier - [https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore](https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore)
|
|
639
|
-
- ESLint - [https://eslint.org/docs/latest/use/configure/ignore#ignoring-files](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files)
|
|
640
|
-
- Biome - [https://biomejs.dev/reference/configuration/#filesignore](https://biomejs.dev/reference/configuration/#filesignore)
|
|
641
|
-
|
|
642
|
-
> [!WARNING]
|
|
643
|
-
> If you are using VSCode, you may experience the route tree file unexpectedly open (with errors) after renaming a route.
|
|
644
|
-
|
|
645
|
-
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:
|
|
646
|
-
|
|
647
|
-
\`\`\`json
|
|
648
|
-
{
|
|
649
|
-
"files.readonlyInclude": {
|
|
650
|
-
"**/routeTree.gen.ts": true
|
|
651
|
-
},
|
|
652
|
-
"files.watcherExclude": {
|
|
653
|
-
"**/routeTree.gen.ts": true
|
|
654
|
-
},
|
|
655
|
-
"search.exclude": {
|
|
656
|
-
"**/routeTree.gen.ts": true
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
\`\`\`
|
|
660
|
-
|
|
661
|
-
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.
|
|
662
|
-
|
|
663
|
-
## Configuration
|
|
664
|
-
|
|
665
|
-
When using the TanStack Router Plugin with Esbuild for File-based routing, it comes with some sane defaults that should work for most projects:
|
|
666
|
-
|
|
667
|
-
\`\`\`json
|
|
668
|
-
{
|
|
669
|
-
"routesDirectory": "./src/routes",
|
|
670
|
-
"generatedRouteTree": "./src/routeTree.gen.ts",
|
|
671
|
-
"routeFileIgnorePrefix": "-",
|
|
672
|
-
"quoteStyle": "single"
|
|
673
|
-
}
|
|
674
|
-
\`\`\`
|
|
675
|
-
|
|
676
|
-
If these defaults work for your project, you don't need to configure anything at all! However, if you need to customize the configuration, you can do so by editing the configuration object passed into the \`tanstackRouter\` function.
|
|
677
|
-
|
|
678
|
-
You can find all the available configuration options in the [File-based Routing API Reference](../../../../api/file-based-routing.md).
|
|
679
|
-
|
|
680
|
-
# Installation with Router CLI
|
|
681
|
-
|
|
682
|
-
> [!WARNING]
|
|
683
|
-
> You should only use the TanStack Router CLI if you are not using a supported bundler. The CLI only supports the generation of the route tree file and does not provide any other features.
|
|
684
|
-
|
|
685
|
-
To use file-based routing with the TanStack Router CLI, you'll need to install the \`@tanstack/router-cli\` package.
|
|
686
|
-
|
|
687
|
-
\`\`\`sh
|
|
688
|
-
npm install -D @tanstack/router-cli
|
|
689
|
-
\`\`\`
|
|
690
|
-
|
|
691
|
-
Once installed, you'll need to amend your scripts in your \`package.json\` for the CLI to \`watch\` and \`generate\` files.
|
|
692
|
-
|
|
693
|
-
\`\`\`json
|
|
694
|
-
{
|
|
695
|
-
"scripts": {
|
|
696
|
-
"generate-routes": "tsr generate",
|
|
697
|
-
"watch-routes": "tsr watch",
|
|
698
|
-
"build": "npm run generate-routes && ...",
|
|
699
|
-
"dev": "npm run watch-routes && ..."
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
\`\`\`
|
|
703
|
-
|
|
704
|
-
[//]: # 'AfterScripts'
|
|
705
|
-
[//]: # 'AfterScripts'
|
|
706
|
-
|
|
707
|
-
You shouldn't forget to _ignore_ the generated route tree file. Head over to the [Ignoring the generated route tree file](#ignoring-the-generated-route-tree-file) section to learn more.
|
|
708
|
-
|
|
709
|
-
With the CLI installed, the following commands are made available via the \`tsr\` command
|
|
710
|
-
|
|
711
|
-
## Using the \`generate\` command
|
|
712
|
-
|
|
713
|
-
Generates the routes for a project based on the provided configuration.
|
|
714
|
-
|
|
715
|
-
\`\`\`sh
|
|
716
|
-
tsr generate
|
|
717
|
-
\`\`\`
|
|
718
|
-
|
|
719
|
-
## Using the \`watch\` command
|
|
720
|
-
|
|
721
|
-
Continuously watches the specified directories and regenerates routes as needed.
|
|
722
|
-
|
|
723
|
-
**Usage:**
|
|
724
|
-
|
|
725
|
-
\`\`\`sh
|
|
726
|
-
tsr watch
|
|
727
|
-
\`\`\`
|
|
728
|
-
|
|
729
|
-
With file-based routing enabled, whenever you start your application in development mode, TanStack Router will watch your configured \`routesDirectory\` and generate your route tree whenever a file is added, removed, or changed.
|
|
730
|
-
|
|
731
|
-
## Ignoring the generated route tree file
|
|
732
|
-
|
|
733
|
-
If your project is configured to use a linter and/or formatter, you may want to ignore the generated route tree file. This file is managed by TanStack Router and therefore shouldn't be changed by your linter or formatter.
|
|
734
|
-
|
|
735
|
-
Here are some resources to help you ignore the generated route tree file:
|
|
736
|
-
|
|
737
|
-
- Prettier - [https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore](https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore)
|
|
738
|
-
- ESLint - [https://eslint.org/docs/latest/use/configure/ignore#ignoring-files](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files)
|
|
739
|
-
- Biome - [https://biomejs.dev/reference/configuration/#filesignore](https://biomejs.dev/reference/configuration/#filesignore)
|
|
740
|
-
|
|
741
|
-
> [!WARNING]
|
|
742
|
-
> If you are using VSCode, you may experience the route tree file unexpectedly open (with errors) after renaming a route.
|
|
743
|
-
|
|
744
|
-
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:
|
|
745
|
-
|
|
746
|
-
\`\`\`json
|
|
747
|
-
{
|
|
748
|
-
"files.readonlyInclude": {
|
|
749
|
-
"**/routeTree.gen.ts": true
|
|
750
|
-
},
|
|
751
|
-
"files.watcherExclude": {
|
|
752
|
-
"**/routeTree.gen.ts": true
|
|
753
|
-
},
|
|
754
|
-
"search.exclude": {
|
|
755
|
-
"**/routeTree.gen.ts": true
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
\`\`\`
|
|
759
|
-
|
|
760
|
-
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.
|
|
761
|
-
|
|
762
|
-
## Configuration
|
|
763
|
-
|
|
764
|
-
When using the TanStack Router CLI for File-based routing, it comes with some sane defaults that should work for most projects:
|
|
765
|
-
|
|
766
|
-
\`\`\`json
|
|
767
|
-
{
|
|
768
|
-
"routesDirectory": "./src/routes",
|
|
769
|
-
"generatedRouteTree": "./src/routeTree.gen.ts",
|
|
770
|
-
"routeFileIgnorePrefix": "-",
|
|
771
|
-
"quoteStyle": "single"
|
|
772
|
-
}
|
|
773
|
-
\`\`\`
|
|
774
|
-
|
|
775
|
-
If these defaults work for your project, you don't need to configure anything at all! However, if you need to customize the configuration, you can do so by creating a \`tsr.config.json\` file in the root of your project directory.
|
|
776
|
-
|
|
777
|
-
[//]: # 'TargetConfiguration'
|
|
778
|
-
[//]: # 'TargetConfiguration'
|
|
779
|
-
|
|
780
|
-
You can find all the available configuration options in the [File-based Routing API Reference](../../../../api/file-based-routing.md).
|
|
781
|
-
|
|
782
|
-
# Installation with Rspack
|
|
783
|
-
|
|
784
|
-
[//]: # 'BundlerConfiguration'
|
|
785
|
-
|
|
786
|
-
To use file-based routing with **Rspack** or **Rsbuild**, you'll need to install the \`@tanstack/router-plugin\` package.
|
|
787
|
-
|
|
788
|
-
\`\`\`sh
|
|
789
|
-
npm install -D @tanstack/router-plugin
|
|
790
|
-
\`\`\`
|
|
791
|
-
|
|
792
|
-
Once installed, you'll need to add the plugin to your configuration.
|
|
793
|
-
|
|
794
|
-
\`\`\`tsx
|
|
795
|
-
// rsbuild.config.ts
|
|
796
|
-
import { defineConfig } from '@rsbuild/core'
|
|
797
|
-
import { pluginReact } from '@rsbuild/plugin-react'
|
|
798
|
-
import { tanstackRouter } from '@tanstack/router-plugin/rspack'
|
|
799
|
-
|
|
800
|
-
export default defineConfig({
|
|
801
|
-
plugins: [pluginReact()],
|
|
802
|
-
tools: {
|
|
803
|
-
rspack: {
|
|
804
|
-
plugins: [
|
|
805
|
-
tanstackRouter({
|
|
806
|
-
target: 'react',
|
|
807
|
-
autoCodeSplitting: true,
|
|
808
|
-
}),
|
|
809
|
-
],
|
|
810
|
-
},
|
|
811
|
-
},
|
|
812
|
-
})
|
|
813
|
-
\`\`\`
|
|
814
|
-
|
|
815
|
-
Or, you can clone our [Quickstart Rspack/Rsbuild example](https://github.com/TanStack/router/tree/main/examples/react/quickstart-rspack-file-based) and get started.
|
|
816
|
-
|
|
817
|
-
Now that you've added the plugin to your Rspack/Rsbuild configuration, you're all set to start using file-based routing with TanStack Router.
|
|
818
|
-
|
|
819
|
-
[//]: # 'BundlerConfiguration'
|
|
820
|
-
|
|
821
|
-
## Ignoring the generated route tree file
|
|
822
|
-
|
|
823
|
-
If your project is configured to use a linter and/or formatter, you may want to ignore the generated route tree file. This file is managed by TanStack Router and therefore shouldn't be changed by your linter or formatter.
|
|
824
|
-
|
|
825
|
-
Here are some resources to help you ignore the generated route tree file:
|
|
826
|
-
|
|
827
|
-
- Prettier - [https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore](https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore)
|
|
828
|
-
- ESLint - [https://eslint.org/docs/latest/use/configure/ignore#ignoring-files](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files)
|
|
829
|
-
- Biome - [https://biomejs.dev/reference/configuration/#filesignore](https://biomejs.dev/reference/configuration/#filesignore)
|
|
830
|
-
|
|
831
|
-
> [!WARNING]
|
|
832
|
-
> If you are using VSCode, you may experience the route tree file unexpectedly open (with errors) after renaming a route.
|
|
833
|
-
|
|
834
|
-
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:
|
|
835
|
-
|
|
836
|
-
\`\`\`json
|
|
837
|
-
{
|
|
838
|
-
"files.readonlyInclude": {
|
|
839
|
-
"**/routeTree.gen.ts": true
|
|
840
|
-
},
|
|
841
|
-
"files.watcherExclude": {
|
|
842
|
-
"**/routeTree.gen.ts": true
|
|
843
|
-
},
|
|
844
|
-
"search.exclude": {
|
|
845
|
-
"**/routeTree.gen.ts": true
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
\`\`\`
|
|
849
|
-
|
|
850
|
-
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.
|
|
851
|
-
|
|
852
|
-
## Configuration
|
|
853
|
-
|
|
854
|
-
When using the TanStack Router Plugin with Rspack (or Rsbuild) for File-based routing, it comes with some sane defaults that should work for most projects:
|
|
855
|
-
|
|
856
|
-
\`\`\`json
|
|
857
|
-
{
|
|
858
|
-
"routesDirectory": "./src/routes",
|
|
859
|
-
"generatedRouteTree": "./src/routeTree.gen.ts",
|
|
860
|
-
"routeFileIgnorePrefix": "-",
|
|
861
|
-
"quoteStyle": "single"
|
|
862
|
-
}
|
|
863
|
-
\`\`\`
|
|
864
|
-
|
|
865
|
-
If these defaults work for your project, you don't need to configure anything at all! However, if you need to customize the configuration, you can do so by editing the configuration object passed into the \`tanstackRouter\` function.
|
|
866
|
-
|
|
867
|
-
You can find all the available configuration options in the [File-based Routing API Reference](../../../../api/file-based-routing.md).
|
|
868
|
-
|
|
869
|
-
# Installation with Vite
|
|
870
|
-
|
|
871
|
-
[//]: # 'BundlerConfiguration'
|
|
872
|
-
|
|
873
|
-
To use file-based routing with **Vite**, you'll need to install the \`@tanstack/router-plugin\` package.
|
|
874
|
-
|
|
875
|
-
\`\`\`sh
|
|
876
|
-
npm install -D @tanstack/router-plugin
|
|
877
|
-
\`\`\`
|
|
878
|
-
|
|
879
|
-
Once installed, you'll need to add the plugin to your Vite configuration.
|
|
880
|
-
|
|
881
|
-
\`\`\`ts
|
|
882
|
-
// vite.config.ts
|
|
883
|
-
import { defineConfig } from 'vite'
|
|
884
|
-
import react from '@vitejs/plugin-react'
|
|
885
|
-
import { tanstackRouter } from '@tanstack/router-plugin/vite'
|
|
886
|
-
|
|
887
|
-
// https://vitejs.dev/config/
|
|
888
|
-
export default defineConfig({
|
|
889
|
-
plugins: [
|
|
890
|
-
// Please make sure that '@tanstack/router-plugin' is passed before '@vitejs/plugin-react'
|
|
891
|
-
tanstackRouter({
|
|
892
|
-
target: 'react',
|
|
893
|
-
autoCodeSplitting: true,
|
|
894
|
-
}),
|
|
895
|
-
react(),
|
|
896
|
-
// ...
|
|
897
|
-
],
|
|
898
|
-
})
|
|
899
|
-
\`\`\`
|
|
900
|
-
|
|
901
|
-
Or, you can clone our [Quickstart Vite example](https://github.com/TanStack/router/tree/main/examples/react/quickstart-file-based) and get started.
|
|
902
|
-
|
|
903
|
-
> [!WARNING]
|
|
904
|
-
> If you are using the older \`@tanstack/router-vite-plugin\` package, you can still continue to use it, as it will be aliased to the \`@tanstack/router-plugin/vite\` package. However, we would recommend using the \`@tanstack/router-plugin\` package directly.
|
|
905
|
-
|
|
906
|
-
Now that you've added the plugin to your Vite configuration, you're all set to start using file-based routing with TanStack Router.
|
|
907
|
-
|
|
908
|
-
[//]: # 'BundlerConfiguration'
|
|
909
|
-
|
|
910
|
-
## Ignoring the generated route tree file
|
|
911
|
-
|
|
912
|
-
If your project is configured to use a linter and/or formatter, you may want to ignore the generated route tree file. This file is managed by TanStack Router and therefore shouldn't be changed by your linter or formatter.
|
|
913
|
-
|
|
914
|
-
Here are some resources to help you ignore the generated route tree file:
|
|
915
|
-
|
|
916
|
-
- Prettier - [https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore](https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore)
|
|
917
|
-
- ESLint - [https://eslint.org/docs/latest/use/configure/ignore#ignoring-files](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files)
|
|
918
|
-
- Biome - [https://biomejs.dev/reference/configuration/#filesignore](https://biomejs.dev/reference/configuration/#filesignore)
|
|
919
|
-
|
|
920
|
-
> [!WARNING]
|
|
921
|
-
> If you are using VSCode, you may experience the route tree file unexpectedly open (with errors) after renaming a route.
|
|
922
|
-
|
|
923
|
-
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:
|
|
924
|
-
|
|
925
|
-
\`\`\`json
|
|
926
|
-
{
|
|
927
|
-
"files.readonlyInclude": {
|
|
928
|
-
"**/routeTree.gen.ts": true
|
|
929
|
-
},
|
|
930
|
-
"files.watcherExclude": {
|
|
931
|
-
"**/routeTree.gen.ts": true
|
|
932
|
-
},
|
|
933
|
-
"search.exclude": {
|
|
934
|
-
"**/routeTree.gen.ts": true
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
\`\`\`
|
|
938
|
-
|
|
939
|
-
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.
|
|
940
|
-
|
|
941
|
-
## Configuration
|
|
942
|
-
|
|
943
|
-
When using the TanStack Router Plugin with Vite for File-based routing, it comes with some sane defaults that should work for most projects:
|
|
944
|
-
|
|
945
|
-
\`\`\`json
|
|
946
|
-
{
|
|
947
|
-
"routesDirectory": "./src/routes",
|
|
948
|
-
"generatedRouteTree": "./src/routeTree.gen.ts",
|
|
949
|
-
"routeFileIgnorePrefix": "-",
|
|
950
|
-
"quoteStyle": "single"
|
|
951
|
-
}
|
|
952
|
-
\`\`\`
|
|
953
|
-
|
|
954
|
-
If these defaults work for your project, you don't need to configure anything at all! However, if you need to customize the configuration, you can do so by editing the configuration object passed into the \`tanstackRouter\` function.
|
|
955
|
-
|
|
956
|
-
You can find all the available configuration options in the [File-based Routing API Reference](../../../../api/file-based-routing.md).
|
|
957
|
-
|
|
958
|
-
# Installation with Webpack
|
|
959
|
-
|
|
960
|
-
[//]: # 'BundlerConfiguration'
|
|
961
|
-
|
|
962
|
-
To use file-based routing with **Webpack**, you'll need to install the \`@tanstack/router-plugin\` package.
|
|
963
|
-
|
|
964
|
-
\`\`\`sh
|
|
965
|
-
npm install -D @tanstack/router-plugin
|
|
966
|
-
\`\`\`
|
|
967
|
-
|
|
968
|
-
Once installed, you'll need to add the plugin to your configuration.
|
|
969
|
-
|
|
970
|
-
\`\`\`tsx
|
|
971
|
-
// webpack.config.ts
|
|
972
|
-
import { tanstackRouter } from '@tanstack/router-plugin/webpack'
|
|
973
|
-
|
|
974
|
-
export default {
|
|
975
|
-
plugins: [
|
|
976
|
-
tanstackRouter({
|
|
977
|
-
target: 'react',
|
|
978
|
-
autoCodeSplitting: true,
|
|
979
|
-
}),
|
|
980
|
-
],
|
|
981
|
-
}
|
|
982
|
-
\`\`\`
|
|
983
|
-
|
|
984
|
-
Or, you can clone our [Quickstart Webpack example](https://github.com/TanStack/router/tree/main/examples/react/quickstart-webpack-file-based) and get started.
|
|
985
|
-
|
|
986
|
-
Now that you've added the plugin to your Webpack configuration, you're all set to start using file-based routing with TanStack Router.
|
|
987
|
-
|
|
988
|
-
[//]: # 'BundlerConfiguration'
|
|
989
|
-
|
|
990
|
-
## Ignoring the generated route tree file
|
|
991
|
-
|
|
992
|
-
If your project is configured to use a linter and/or formatter, you may want to ignore the generated route tree file. This file is managed by TanStack Router and therefore shouldn't be changed by your linter or formatter.
|
|
993
|
-
|
|
994
|
-
Here are some resources to help you ignore the generated route tree file:
|
|
995
|
-
|
|
996
|
-
- Prettier - [https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore](https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore)
|
|
997
|
-
- ESLint - [https://eslint.org/docs/latest/use/configure/ignore#ignoring-files](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files)
|
|
998
|
-
- Biome - [https://biomejs.dev/reference/configuration/#filesignore](https://biomejs.dev/reference/configuration/#filesignore)
|
|
999
|
-
|
|
1000
|
-
> [!WARNING]
|
|
1001
|
-
> If you are using VSCode, you may experience the route tree file unexpectedly open (with errors) after renaming a route.
|
|
1002
|
-
|
|
1003
|
-
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:
|
|
1004
|
-
|
|
1005
|
-
\`\`\`json
|
|
1006
|
-
{
|
|
1007
|
-
"files.readonlyInclude": {
|
|
1008
|
-
"**/routeTree.gen.ts": true
|
|
1009
|
-
},
|
|
1010
|
-
"files.watcherExclude": {
|
|
1011
|
-
"**/routeTree.gen.ts": true
|
|
1012
|
-
},
|
|
1013
|
-
"search.exclude": {
|
|
1014
|
-
"**/routeTree.gen.ts": true
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
\`\`\`
|
|
1018
|
-
|
|
1019
|
-
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.
|
|
1020
|
-
|
|
1021
|
-
## Configuration
|
|
1022
|
-
|
|
1023
|
-
When using the TanStack Router Plugin with Webpack for File-based routing, it comes with some sane defaults that should work for most projects:
|
|
1024
|
-
|
|
1025
|
-
\`\`\`json
|
|
1026
|
-
{
|
|
1027
|
-
"routesDirectory": "./src/routes",
|
|
1028
|
-
"generatedRouteTree": "./src/routeTree.gen.ts",
|
|
1029
|
-
"routeFileIgnorePrefix": "-",
|
|
1030
|
-
"quoteStyle": "single"
|
|
1031
|
-
}
|
|
1032
|
-
\`\`\`
|
|
1033
|
-
|
|
1034
|
-
If these defaults work for your project, you don't need to configure anything at all! However, if you need to customize the configuration, you can do so by editing the configuration object passed into the \`tanstackRouter\` function.
|
|
1035
|
-
|
|
1036
|
-
You can find all the available configuration options in the [File-based Routing API Reference](../../../../api/file-based-routing.md).
|
|
1037
|
-
|
|
1038
599
|
# Route Matching
|
|
1039
600
|
|
|
1040
601
|
Route matching follows a consistent and predictable pattern. This guide will explain how route trees are matched.
|