@tanstack/react-router 1.129.8 → 1.129.9

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.
@@ -164,6 +164,22 @@ You can _optionally_, also use the [Non-Redirected Authentication](#non-redirect
164
164
 
165
165
  This approach can also be used in conjunction with Pathless or Layout Route to protect all routes under their parent route.
166
166
 
167
+ ## Related How-To Guides
168
+
169
+ For detailed, step-by-step implementation guides, see:
170
+
171
+ - [How to Set Up Basic Authentication](../how-to/setup-authentication.md) - Complete setup with React Context and protected routes
172
+ - [How to Integrate Authentication Providers](../how-to/setup-auth-providers.md) - Use Auth0, Clerk, or Supabase
173
+ - [How to Set Up Role-Based Access Control](../how-to/setup-rbac.md) - Implement permissions and role-based routing
174
+
175
+ ## Examples
176
+
177
+ Working authentication examples are available in the repository:
178
+
179
+ - [Basic Authentication Example](https://github.com/TanStack/router/tree/main/examples/react/authenticated-routes) - Simple authentication with context
180
+ - [Firebase Authentication](https://github.com/TanStack/router/tree/main/examples/react/authenticated-routes-firebase) - Firebase Auth integration
181
+ - [TanStack Start Auth Examples](https://github.com/TanStack/router/tree/main/examples/react) - Various auth implementations with TanStack Start
182
+
167
183
  # Automatic Code Splitting
168
184
 
169
185
  The automatic code splitting feature in TanStack Router allows you to optimize your application's bundle size by lazily loading route components and their associated data. This is particularly useful for large applications where you want to minimize the initial load time by only loading the necessary code for the current route.
@@ -361,7 +377,7 @@ export default defineConfig({
361
377
  })
362
378
  \`\`\`
363
379
 
364
- We highly discourage splitting the \`loader\` unless you have a specific use case that requires it. In most cases, keeping the \`loader\` bundled with the component is the best choice for performance.
380
+ We highly discourage splitting the \`loader\` unless you have a specific use case that requires it. In most cases, not splitting off the \`loader\` and keep it in the main bundle is the best choice for performance.
365
381
 
366
382
  # Code Splitting
367
383
 
@@ -376,7 +392,6 @@ Code splitting and lazy loading is a powerful technique for improving the bundle
376
392
  TanStack Router separates code into two categories:
377
393
 
378
394
  - **Critical Route Configuration** - The code that is required to render the current route and kick off the data loading process as early as possible.
379
-
380
395
  - Path Parsing/Serialization
381
396
  - Search Param Validation
382
397
  - Loaders, Before Load
@@ -796,59 +811,38 @@ Here are some examples of how you can use \`createLink\` with third-party librar
796
811
 
797
812
  ### React Aria Components example
798
813
 
799
- React Aria Components'
800
- [Link](https://react-spectrum.adobe.com/react-aria/Link.html) component does not support the standard \`onMouseEnter\` and \`onMouseLeave\` events.
801
- Therefore, you cannot use it directly with TanStack Router's \`preload (intent)\` prop.
814
+ React Aria Components v1.11.0 and later works with TanStack Router's \`preload (intent)\` prop. Use \`createLink\` to wrap each React Aria component that you use as a link.
802
815
 
803
- Explanation for this can be found here:
816
+ \`\`\`tsx
817
+ import { createLink } from '@tanstack/react-router'
818
+ import { Link as RACLink, MenuItem } from 'react-aria-components'
804
819
 
805
- - [https://react-spectrum.adobe.com/react-aria/interactions.html](https://react-spectrum.adobe.com/react-aria/interactions.html)
806
- - [https://react-spectrum.adobe.com/blog/building-a-button-part-2.html](https://react-spectrum.adobe.com/blog/building-a-button-part-2.html)
820
+ export const Link = createLink(RACLink)
821
+ export const MenuItemLink = createLink(MenuItem)
822
+ \`\`\`
807
823
 
808
- It is possible to work around this by using the [useLink](https://react-spectrum.adobe.com/react-aria/useLink.html) hook from [React Aria Hooks](https://react-spectrum.adobe.com/react-aria/hooks.html) with a standard anchor element.
824
+ To use React Aria's render props, including the \`className\`, \`style\`, and \`children\` functions, create a wrapper component and pass that to \`createLink\`.
809
825
 
810
826
  \`\`\`tsx
811
- import * as React from 'react'
812
- import { createLink, LinkComponent } from '@tanstack/react-router'
813
- import {
814
- mergeProps,
815
- useFocusRing,
816
- useHover,
817
- useLink,
818
- useObjectRef,
819
- } from 'react-aria'
820
- import type { AriaLinkOptions } from 'react-aria'
827
+ import { createLink } from '@tanstack/react-router'
828
+ import { Link as RACLink, type LinkProps } from 'react-aria-components'
821
829
 
822
- interface RACLinkProps extends Omit<AriaLinkOptions, 'href'> {
823
- children?: React.ReactNode
830
+ interface MyLinkProps extends LinkProps {
831
+ // your props
824
832
  }
825
833
 
826
- const RACLinkComponent = React.forwardRef<HTMLAnchorElement, RACLinkProps>(
827
- (props, forwardedRef) => {
828
- const ref = useObjectRef(forwardedRef)
829
-
830
- const { isPressed, linkProps } = useLink(props, ref)
831
- const { isHovered, hoverProps } = useHover(props)
832
- const { isFocusVisible, isFocused, focusProps } = useFocusRing(props)
833
-
834
- return (
835
- <a
836
- {...mergeProps(linkProps, hoverProps, focusProps, props)}
837
- ref={ref}
838
- data-hovered={isHovered || undefined}
839
- data-pressed={isPressed || undefined}
840
- data-focus-visible={isFocusVisible || undefined}
841
- data-focused={isFocused || undefined}
842
- />
843
- )
844
- },
845
- )
846
-
847
- const CreatedLinkComponent = createLink(RACLinkComponent)
848
-
849
- export const CustomLink: LinkComponent<typeof RACLinkComponent> = (props) => {
850
- return <CreatedLinkComponent preload={'intent'} {...props} />
834
+ function MyLink(props: MyLinkProps) {
835
+ return (
836
+ <RACLink
837
+ {...props}
838
+ style={({ isHovered }) => ({
839
+ color: isHovered ? 'red' : 'blue',
840
+ })}
841
+ />
842
+ )
851
843
  }
844
+
845
+ export const Link = createLink(MyLink)
852
846
  \`\`\`
853
847
 
854
848
  ### Chakra UI example
@@ -2112,9 +2106,9 @@ export const Route = createRootRoute({
2112
2106
  children: \`p {
2113
2107
  color: blue;
2114
2108
  background-color: yellow;
2115
- }\`
2116
- }
2117
- ]
2109
+ }\`,
2110
+ },
2111
+ ],
2118
2112
  scripts: [
2119
2113
  {
2120
2114
  src: 'https://www.google-analytics.com/analytics.js',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.129.8",
3
+ "version": "1.129.9",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -80,7 +80,7 @@
80
80
  "tiny-invariant": "^1.3.3",
81
81
  "tiny-warning": "^1.0.3",
82
82
  "@tanstack/history": "1.129.7",
83
- "@tanstack/router-core": "1.129.8"
83
+ "@tanstack/router-core": "1.129.9"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@testing-library/jest-dom": "^6.6.3",