Exposes the `ClientOnly` component for preventing rendering & hydration
errors.
## Background
When you attempt to prevent content from rendering using something like
`typeof document !== 'undefined'` as that type of conditional will cause
hydration errors.
## API
```tsx
import { ClientOnly, createRoute } from '@tanstack/react-router'
import { Charts, FallbackCharts } from './charts-that-break-server-side-rendering'
const Route = createRoute({
// ... other route options
path: '/dashboard',
component: Dashboard,
})
function Dashboard() {
return (
<div>
<p>Dashboard</p>
<ClientOnly fallback={<FallbackCharts />}>
<Charts />
</ClientOnly>
</div>
)
}
```
> [!NOTE]
> This component as is (other than I removed the `children` as a
`function`) in production on [joggr.io](https://joggr.io)
---------
Co-authored-by: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com>
Co-authored-by: Ahmed Abdelbaset <A7med3bdulBaset@gmail.com>
Co-authored-by: Birk Skyum <birk.skyum@pm.me>
The migration to `router-core` made the `redirect` function
more restrictive since it _only_ used the `RegisteredRouter`.
This change makes it so that it accepts `AnyRouter` with it
defaulting to the `RegisteredRouter`. Also, `TTo` also
needed to be changed, since the first generic became optional.
fixes https://github.com/TanStack/router/issues/3680
It seems like `resolvedLocation` does not always point to the latest
location state in the ref callback; sometimes it points to the previous
location and `onRendered` is not triggered.
Also this fix detaches `onRendered` event from the scroll restoration
feature.
This change hashes the generated filnames for the JSON blobs that used
for static server function RPC calls.
So it goes from being
```
/__tsr/staticServerFnCache/app_routes_nav_posts_stub_tsx--loadPostServerFn_createServerFn_handler__-this-is-a-post-slug-.json
```
to
```
/__tsr/staticServerFnCache/00e9f7af882c994097f011e6492f2a30e8754bb0.json
```
This has an added benefit of ensuring that the `sha1` hash names are
always the same in character length.
Closes#3655
Switch out our `qss` implementation from its manual solution
over to using `URLSearchParams` for handling
encoding/decoding while still retaining the same interface.
---------
Co-authored-by: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com>
Fixes#3741
Added hash scroll handling directly in the React `Transitioner`
component's `onResolved`, similar to how it's implemented in the Solid
version
In the "search params" guide, the usage of the variable
`allProductsRoute` has been changed to `Route` in the code-block
examples for consistency and clarity.
This makes the examples easier to follow since `Route` is used
throughout the rest of the documentation.
## Changes
1. **Fix createRootRoute syntax**: Updated all examples in the document
head management guide to use the correct `createRootRoute({...})` syntax
instead of the incorrect `createRootRoute()({...})` syntax.
2. **Fix HeadContent placement**: The previous commit corrected the code
example for Single-Page Applications to properly show the correct syntax
for creating a root route with HeadContent.
## Why these changes matter
- The incorrect syntax examples could lead to confusion for developers
implementing document head management in their applications
- These fixes ensure consistency throughout the documentation and
provide developers with the correct implementation patterns
- Proper documentation helps reduce support requests and improves
developer experience
## Technical details
- Fixed 5 instances of incorrect `createRootRoute()({...})` syntax
throughout the document
- Previously fixed the SPA example which had an incorrect API reference
These changes ensure that all code examples in the document head
management guide are correct and consistent with the actual API
implementation.
The `.matchRoute` method on the Router type page previously stated it
returns a `RouteMatch` object. In reality, it returns only the route
match's params.
This update corrects the return type in docs to reflect actual behavior.
Fix#3875
Currently, when the code-splitter encounters a known identifier used for
configuration in `createFileRoute` (such as `component`, `loader`,
`errorComponent`, etc.) it retains the export without splitting it out
into a separate file.
This functionality is currently partially working when the export is a
"default export" which references an already declared identifier.
```ts
const loader = () => {}
export default loader
```
However, it does not work when the "default export" is also making a
function declaration for the export.
```ts
export default function loader() {}
```
This PR adds the functionality to detect this use case and perform the
same transformations to align itself with the behaviour for all others
exports.