Skip to content

Commit c376140

Browse files
committed
fix: cache nitro app instance in global
1 parent 5f37156 commit c376140

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/runtime/internal/app.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare global {
3434
}
3535

3636
export function useNitroApp(): NitroApp {
37-
return ((useNitroApp as any).__instance__ ??= initNitroApp());
37+
return (globalThis.__nitro__ ??= initNitroApp());
3838
}
3939

4040
export function useNitroHooks(): HookableCore<NitroRuntimeHooks> {
@@ -83,7 +83,7 @@ export function fetch(
8383
}
8484

8585
function initNitroApp(): NitroApp {
86-
const nitroApp = createNitroApp();
86+
const nitroApp = (globalThis.__nitro__ = createNitroApp());
8787
if (hasPlugins) {
8888
for (const plugin of plugins) {
8989
try {
@@ -96,7 +96,6 @@ function initNitroApp(): NitroApp {
9696
}
9797
}
9898
}
99-
globalThis.__nitro__ = nitroApp;
10099
return nitroApp;
101100
}
102101

0 commit comments

Comments
 (0)