-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathrouter.tsx.ejs
66 lines (61 loc) · 1.85 KB
/
router.tsx.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { createRouter as createTanstackRouter } from '@tanstack/react-router'<% if (addOnEnabled.sentry) { %>
import * as Sentry from '@sentry/react'
import * as SentryServer from '@sentry/node'
import { createIsomorphicFn } from '@tanstack/react-start'
<% } %><% if (addOnEnabled['tanstack-query']) { %>
import { routerWithQueryClient } from '@tanstack/react-router-with-query'
import * as TanstackQuery from './integrations/tanstack-query/root-provider'
<% } %>
// Import the generated route tree
import { routeTree } from './routeTree.gen'
import './styles.css'
// Create a new router instance
export const createRouter = () => {
<% if (addOnEnabled['tanstack-query']) { %>
const router = routerWithQueryClient(createTanstackRouter({
routeTree,
context: {
<% if (addOnEnabled['tanstack-query']) { %>
...TanstackQuery.getContext(),
<% } %>
},
scrollRestoration: true,
}), TanstackQuery.getContext().queryClient)
<% } else { %>
const router = createTanstackRouter({
routeTree,
scrollRestoration: true,
})
<% } %>
return router
}
<% if (addOnEnabled.sentry) { %>
const router = createRouter()
createIsomorphicFn().server(() => {
SentryServer.init({
dsn: import.meta.env.VITE_SENTRY_DSN,
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
})
}).client(() => {
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN,
integrations: [
Sentry.replayIntegration({
maskAllText: false,
blockAllMedia: false,
}),
Sentry.tanstackRouterBrowserTracingIntegration(router),
],
tracesSampleRate: 1.0,
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
})
})()
<% } %>
// Register the router instance for type safety
declare module '@tanstack/react-router' {
interface Register {
router: typeof router
}
}