Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions apps/console-v5/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ import { Auth0Wrapper, useAuth0Context } from './auth/auth0'
// Import the generated route tree
import { routeTree } from './routeTree.gen'

// Create a new router instance
const router = createRouter({ routeTree })

type ToastArgs = {
status?: ToastEnum
title: string
Expand Down Expand Up @@ -51,13 +48,6 @@ interface _MutationMeta {
notifyOnError?: boolean | { title: string; description?: string }
}

// Register the router instance for type safety
declare module '@tanstack/react-router' {
interface Register {
router: typeof router
}
}

declare module '@tanstack/react-query' {
interface MutationMeta extends _MutationMeta {}
interface QueryMeta extends _QueryMeta {}
Expand Down Expand Up @@ -136,6 +126,9 @@ const queryClient = new QueryClient({
function InnerApp() {
const auth = useAuth0Context()

// Create a new router instance
const router = createRouter({ routeTree, context: { auth, queryClient } })

if (auth.isLoading) {
return (
<div className="flex min-h-screen items-center justify-center">
Expand Down
11 changes: 9 additions & 2 deletions apps/console-v5/src/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { Outlet, createRootRoute } from '@tanstack/react-router'
import { type QueryClient } from '@tanstack/react-query'
import { Outlet, createRootRouteWithContext } from '@tanstack/react-router'
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
import { type Auth0ContextType } from '../auth/auth0'

interface RouterContext {
auth: Auth0ContextType
queryClient: QueryClient
}

const RootLayout = () => {
return (
Expand All @@ -10,4 +17,4 @@ const RootLayout = () => {
)
}

export const Route = createRootRoute({ component: RootLayout })
export const Route = createRootRouteWithContext<RouterContext>()({ component: RootLayout })