File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1+ import type { LoaderFunctionArgs } from '@remix-run/node'
2+ import { useLoaderData } from '@remix-run/react'
3+
4+ export const loader = ( args : LoaderFunctionArgs ) => {
5+ const extra = args . context . extra
6+ const url = args . context . url
7+ return { extra, url }
8+ }
9+
110export default function Index ( ) {
11+ const { extra, url } = useLoaderData < typeof loader > ( )
212 return (
313 < div >
414 < h1 > Remix and Hono</ h1 >
15+ < h2 > URL is { url } </ h2 >
16+ < h3 > Extra is { extra } </ h3 >
517 </ div >
618 )
719}
Original file line number Diff line number Diff line change 1+ type GetLoadContextArgs = {
2+ request : Request
3+ }
4+
5+ declare module '@remix-run/node' {
6+ interface AppLoadContext extends ReturnType < typeof getLoadContext > {
7+ url : string
8+ extra : string
9+ }
10+ }
11+
12+ export function getLoadContext ( args : GetLoadContextArgs ) {
13+ return {
14+ url : args . request . url ,
15+ extra : 'stuff' ,
16+ }
17+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { serve } from '@hono/node-server'
33import { serveStatic } from '@hono/node-server/serve-static'
44import handle from 'hono-remix-adapter/node'
55import * as build from './build/server'
6+ import { getLoadContext } from './load-context'
67import server from './server'
78
89server . use (
@@ -11,4 +12,6 @@ server.use(
1112 } )
1213)
1314
14- serve ( handle ( build , server ) )
15+ const handler = handle ( build , server , { getLoadContext } )
16+
17+ serve ( { fetch : handler . fetch , port : 3010 } )
You can’t perform that action at this time.
0 commit comments