Skip to content

Commit

Permalink
Minor changes for Start template (#29)
Browse files Browse the repository at this point in the history
- Add fix to use typeof router to correctly reference the type of the
router instance
- Corrected usage for scrollRestoration placement
- Fix forbidden non-null assertion
  • Loading branch information
kyziq authored Feb 26, 2025
1 parent 33ace14 commit 12b3102
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 2 additions & 4 deletions templates/react/add-on/start/assets/src/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { StartClient } from '@tanstack/start'

import { createRouter } from './router'

const router = createRouter({
scrollRestoration: true,
})
const router = createRouter()

hydrateRoot(document!, <StartClient router={router} />)
hydrateRoot(document, <StartClient router={router} />)
7 changes: 5 additions & 2 deletions templates/react/add-on/start/assets/src/router.tsx.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import './styles.css'

// Create a new router instance
export const createRouter = () => {
const router = createTanstackRouter({ routeTree })
const router = createTanstackRouter({
routeTree,
scrollRestoration: true,
})
return router
}

Expand Down Expand Up @@ -46,6 +49,6 @@ const router = createRouter()
// Register the router instance for type safety
declare module '@tanstack/react-router' {
interface Register {
router: router
router: typeof router
}
}

0 comments on commit 12b3102

Please sign in to comment.