Skip to content

Commit 426b315

Browse files
Extract router context to separate file
Co-authored-by: me <[email protected]>
1 parent ff7fc72 commit 426b315

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

server/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
type ServerBuild,
1515
createContext,
1616
} from 'react-router'
17+
import { serverBuildContext } from './router-context'
1718

1819
const MODE = process.env.NODE_ENV ?? 'development'
1920
const IS_PROD = MODE === 'production'
@@ -201,11 +202,6 @@ if (!ALLOW_INDEXING) {
201202
})
202203
}
203204

204-
const serverBuildContext = createContext<Promise<{
205-
error: unknown
206-
build: ServerBuild
207-
}> | null>(null)
208-
209205
app.all(
210206
'*',
211207
createRequestHandler({

server/router-context.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createContext, type ServerBuild } from 'react-router'
2+
3+
// Shared context key for passing the built routes into loaders (e.g. sitemap)
4+
export const serverBuildContext = createContext<
5+
Promise<{ error: unknown; build: ServerBuild }> | null
6+
>(null)
7+

0 commit comments

Comments
 (0)