Open History to see the last commit
1---
2id: client-entry-point
3title: Client Entry Point
4---
5β
6> [!NOTE]
7> The client entry point is **optional** out of the box. If not provided, TanStack Start will automatically handle the client entry point for you using the below as a default.
8β
9Getting our html to the client is only half the battle. Once there, we need to hydrate our client-side JavaScript once the route resolves to the client. We do this by hydrating the root of our application with the `StartClient` component:
10β
11```tsx
12// src/client.tsx
13import { hydrate } from 'solid-js/web'
14import { StartClient, hydrateStart } from '@tanstack/solid-start/client'
15β
16hydrateStart().then((router) => {
17 hydrate(() => <StartClient router={router} />, document)
18})
19```
20β
21This enables us to kick off client-side routing once the user's initial server request has fulfilled.
22β
23## Error Handling
24β
25You can wrap your client entry point with error boundaries to handle client-side errors gracefully:
26β
27```tsx
28// src/client.tsx
29import { StartClient } from '@tanstack/solid-start/client'
30import { hydrate } from 'solid-js/web'
31import { ErrorBoundary } from './components/ErrorBoundary'
32β
33hydrate(
34 () => (
35 <ErrorBoundary>
36 <StartClient />
37 </ErrorBoundary>
38 ),
39 document.body,
40)
41```
42β
43## Development vs Production
44β
45You may want different behavior in development vs production:
46β
47```tsx
48// src/client.tsx
49import { StartClient } from '@tanstack/solid-start/client'
50import { hydrate } from 'solid-js/web'
51β
52const App = (
53 <>
54 {import.meta.env.DEV && <div>Development Mode</div>}
55 <StartClient />
56 </>
57)
58β
59hydrate(() => <App />, document.body)
60```
61β
62The client entry point gives you full control over how your application initializes on the client side while working seamlessly with TanStack Start's server-side rendering.