0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-18 19:34:24 +00:00
router/packages/solid-router/src
Zac Rosenbauer f0138f80b0
feat(react-router): Export ClientOnly (#3969)
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>
History 2025-04-13 10:50:44 +02:00
..
Asset.tsx fix(solid-router): make HeadContent work for client navigation (#3616) 2025-03-01 13:10:44 +01:00
awaited.tsx fix(solid-router): use createResource and Show in Await (#3591) 2025-02-27 14:30:51 +01:00
CatchBoundary.tsx feat(solid-router): Add a SolidJS driver for TanStack Router (#3276) 2025-02-20 17:11:39 +01:00
ClientOnly.tsx feat(react-router): Export ClientOnly (#3969) 2025-04-13 10:50:44 +02:00
fileRoute.ts fix: use fullPath as from in Route/RouteApi useNavigate (#3684) 2025-03-06 23:58:51 +01:00
HeadContent.tsx fix(solid-router): make HeadContent work for client navigation (#3616) 2025-03-01 13:10:44 +01:00
history.ts feat(solid-router): Add a SolidJS driver for TanStack Router (#3276) 2025-02-20 17:11:39 +01:00
index.tsx feat(react-router): Export ClientOnly (#3969) 2025-04-13 10:50:44 +02:00
lazyRouteComponent.tsx feat(react-router): Export ClientOnly (#3969) 2025-04-13 10:50:44 +02:00
link.tsx fix: rebuild link if matches change (#3674) 2025-03-06 01:36:16 +01:00
Match.tsx refactor(router-core): move isNotFound and isRedirect to router-core (#3725) 2025-03-10 10:10:02 +01:00
matchContext.tsx feat(solid-router): Add a SolidJS driver for TanStack Router (#3276) 2025-02-20 17:11:39 +01:00
Matches.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
not-found.tsx refactor(router-core): move isNotFound and isRedirect to router-core (#3725) 2025-03-10 10:10:02 +01:00
renderRouteNotFound.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
route.ts refactor(router-core): moving internals of Router to router core (#3800) 2025-03-18 19:26:13 +01:00
router.ts refactor(router-core): moving internals of Router to router core (#3800) 2025-03-18 19:26:13 +01:00
routerContext.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
RouterProvider.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
SafeFragment.tsx feat(solid-router): Add a SolidJS driver for TanStack Router (#3276) 2025-02-20 17:11:39 +01:00
ScriptOnce.tsx feat(solid-router): Add a SolidJS driver for TanStack Router (#3276) 2025-02-20 17:11:39 +01:00
Scripts.tsx feat(solid-router): Add a SolidJS driver for TanStack Router (#3276) 2025-02-20 17:11:39 +01:00
scroll-restoration.tsx fix(router-core): agnostic scroll restoration (#3740) 2025-03-11 18:46:51 +01:00
ScrollRestoration.tsx fix(router-core): agnostic scroll restoration (#3740) 2025-03-11 18:46:51 +01:00
Transitioner.tsx fix(react-router): restore scroll position onResolved (#3914) 2025-04-02 20:37:36 +02:00
typePrimitives.ts fix(router-core): move typePrimitives to shared package (#3748) 2025-03-12 13:30:19 +01:00
useBlocker.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
useCanGoBack.ts feat(solid-router): Add a SolidJS driver for TanStack Router (#3276) 2025-02-20 17:11:39 +01:00
useLoaderData.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
useLoaderDeps.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
useLocation.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
useMatch.tsx fix(router-core): move ThrowConstraint to core utils (#3749) 2025-03-12 13:54:05 +01:00
useNavigate.tsx fix: use default from in useNavigate (#3671) 2025-03-05 22:15:21 +01:00
useParams.tsx fix(router-core): move ThrowConstraint to core utils (#3749) 2025-03-12 13:54:05 +01:00
useRouteContext.ts refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
useRouter.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
useRouterState.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
useSearch.tsx fix(router-core): move ThrowConstraint to core utils (#3749) 2025-03-12 13:54:05 +01:00
utils.ts refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00