Skip to content

Commit e1419d7

Browse files
authored
fix: never use global context on the server side
1 parent 1ec622d commit e1419d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/pinia/src/rootStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ interface _SetActivePinia {
4343
* Get the currently active pinia if there is any.
4444
*/
4545
export const getActivePinia = () =>
46-
(hasInjectionContext() && inject(piniaSymbol)) || activePinia
46+
(hasInjectionContext() && inject(piniaSymbol)) || (import.meta.server ? throw new Error("Cannot get active pinia as it does not find context") : activePinia)
4747

4848
/**
4949
* Every application must own its own pinia to be able to create stores

0 commit comments

Comments
 (0)