File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed 
packages/nuxt/src/runtime Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ export default (context: any, inject: any) => {
1010  context . app . pinia  =  pinia 
1111  setActivePinia ( pinia ) 
1212
13+   // add access to `$nuxt` 
14+   // @ts -expect-error: _p is internal 
15+   pinia . _p . push ( ( {  store } )  =>  { 
16+     // make it non enumerable so it avoids any serialization and devtools 
17+     Object . defineProperty ( store ,  '$nuxt' ,  {  value : context  } ) 
18+   } ) 
19+ 
1320  if  ( process . server )  { 
1421    context . beforeNuxtRender ( ( ctx : any )  =>  { 
1522      ctx . nuxtState . pinia  =  pinia . state . value 
@@ -21,3 +28,13 @@ export default (context: any, inject: any) => {
2128  // Inject $pinia 
2229  inject ( 'pinia' ,  pinia ) 
2330} 
31+ 
32+ declare  module 'pinia'  { 
33+   export  interface  PiniaCustomProperties  { 
34+     /** 
35+      * Nuxt context. 
36+      */ 
37+     // FIXME: where is this type? 
38+     // $nuxt: import('@nuxt/types').Context 
39+   } 
40+ } 
Original file line number Diff line number Diff line change @@ -6,6 +6,12 @@ export default defineNuxtPlugin((nuxtApp) => {
66  nuxtApp . vueApp . use ( pinia ) 
77  setActivePinia ( pinia ) 
88
9+   // @ts -expect-error: _p is internal 
10+   pinia . _p . push ( ( {  store } )  =>  { 
11+     // make it non enumerable so it avoids any serialization and devtools 
12+     Object . defineProperty ( store ,  '$nuxt' ,  {  value : nuxtApp  } ) 
13+   } ) 
14+ 
915  if  ( process . server )  { 
1016    nuxtApp . payload . pinia  =  pinia . state . value 
1117  }  else  if  ( nuxtApp . payload  &&  nuxtApp . payload . pinia )  { 
@@ -19,3 +25,13 @@ export default defineNuxtPlugin((nuxtApp) => {
1925    } , 
2026  } 
2127} ) 
28+ 
29+ declare  module 'pinia'  { 
30+   export  interface  PiniaCustomProperties  { 
31+     /** 
32+      * Nuxt context. 
33+      */ 
34+     // FIXME: where is this type? 
35+     // $nuxt: import('@nuxt/types').Context 
36+   } 
37+ } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments