Open History to see the last commit
1import * as React from 'react'
2import type { AnyRouter } from '@tanstack/router-core'
3β
4declare global {
5 interface Window {
6 __TSR_ROUTER_CONTEXT__?: React.Context<AnyRouter>
7 }
8}
9β
10const routerContext = React.createContext<AnyRouter>(null!)
11β
12export function getRouterContext() {
13 if (typeof document === 'undefined') {
14 return routerContext
15 }
16β
17 if (window.__TSR_ROUTER_CONTEXT__) {
18 return window.__TSR_ROUTER_CONTEXT__
19 }
20β
21 window.__TSR_ROUTER_CONTEXT__ = routerContext as any
22β
23 return routerContext
24}