File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,15 +30,22 @@ import {
3030} from "#nitro/virtual/feature-flags" ;
3131
3232declare global {
33- var __nitro__ : NitroApp | undefined ;
33+ var __nitro__ :
34+ | Partial <
35+ Record < "default" | "prerender" | ( string & { } ) , NitroApp | undefined >
36+ >
37+ | undefined ;
3438}
3539
36- export function useNitroApp ( ) : NitroApp {
37- return ( globalThis . __nitro__ ??= initNitroApp ( ) ) ;
40+ const APP_ID = import . meta. prerender ? "prerender" : "default" ;
41+
42+ export function useNitroApp ( _id = APP_ID ) : NitroApp {
43+ globalThis . __nitro__ ??= { } ;
44+ return ( globalThis . __nitro__ [ _id ] ??= initNitroApp ( ) ) ;
3845}
3946
40- export function useNitroHooks ( ) : HookableCore < NitroRuntimeHooks > {
41- const nitroApp = useNitroApp ( ) ;
47+ export function useNitroHooks ( _id = APP_ID ) : HookableCore < NitroRuntimeHooks > {
48+ const nitroApp = useNitroApp ( _id ) ;
4249 const hooks = nitroApp . hooks ;
4350 if ( hooks ) {
4451 return hooks ;
Original file line number Diff line number Diff line change @@ -20,7 +20,10 @@ export function serverFetch(
2020 init ?: RequestInit ,
2121 context ?: ServerRequestContext | H3EventContext
2222) : Promise < Response > {
23- const nitro = globalThis . __nitro__ || globalThis . __nitro_builder__ ;
23+ const nitro =
24+ globalThis . __nitro__ ?. default ||
25+ globalThis . __nitro__ ?. prerender ||
26+ globalThis . __nitro_builder__ ;
2427 if ( ! nitro ) {
2528 return Promise . reject ( new Error ( "Nitro instance is not available." ) ) ;
2629 }
You can’t perform that action at this time.
0 commit comments