@@ -143,20 +143,12 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
143143 ] )
144144 }
145145
146- if ( options . admin ) {
147- if ( ! nuxt . options . ssr ) {
148- console . warn (
149- '[VueFire]: The "admin" option is only used during SSR. You should reenable ssr to use it.'
150- )
151- }
152- addPlugin ( resolve ( runtimeDir , 'admin/plugin.server' ) )
153- }
154-
155146 if ( options . appCheck ) {
156- addPlugin ( resolve ( runtimeDir , 'app-check/plugin' ) )
147+ addPlugin ( resolve ( runtimeDir , 'app-check/plugin.client' ) )
148+ addPlugin ( resolve ( runtimeDir , 'app-check/plugin.server' ) )
157149 }
158150
159- // plugin are added in reverse order
151+ // this adds the VueFire plugin and handle SSR state serialization and hydration
160152 addPluginTemplate ( {
161153 src : normalize ( resolve ( templatesDir , 'plugin.ejs' ) ) ,
162154
@@ -167,7 +159,22 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
167159 } )
168160
169161 // adds the firebase app to each application
170- addPlugin ( resolve ( runtimeDir , 'app/plugin' ) )
162+ addPlugin ( resolve ( runtimeDir , 'app/plugin.client' ) )
163+ addPlugin ( resolve ( runtimeDir , 'app/plugin.server' ) )
164+
165+ // we start the admin app first so we can have access to the user uid everywhere
166+ if ( options . admin ) {
167+ if ( ! nuxt . options . ssr ) {
168+ console . warn (
169+ '[VueFire]: The "admin" option is only used during SSR. You should reenable ssr to use it.'
170+ )
171+ }
172+ // this plugin adds the user so it's accessible directly in the app as well
173+ if ( options . auth ) {
174+ addPlugin ( resolve ( runtimeDir , 'admin/plugin-auth-user.server' ) )
175+ }
176+ addPlugin ( resolve ( runtimeDir , 'admin/plugin.server' ) )
177+ }
171178
172179 addVueFireImports ( [
173180 // app
@@ -186,6 +193,7 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
186193 } ,
187194 } )
188195
196+ // just to have autocomplete and errors
189197type VueFireModuleExportKeys = keyof Awaited < typeof import ( 'vuefire' ) >
190198function addVueFireImports (
191199 imports : Array < {
@@ -231,12 +239,12 @@ declare module '@nuxt/schema' {
231239declare module '#app' {
232240 interface NuxtApp {
233241 $firebaseApp : FirebaseApp
234- $adminApp : FirebaseAdminApp
242+ $firebaseAdminApp : FirebaseAdminApp
235243 }
236244}
237245declare module '@vue/runtime-core' {
238246 interface ComponentCustomProperties {
239247 $firebaseApp : FirebaseApp
240- $adminApp : FirebaseAdminApp
248+ $firebaseAdminApp : FirebaseAdminApp
241249 }
242250}
0 commit comments