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