@@ -15,6 +15,7 @@ import type {
1515 ServiceAccount ,
1616 App as FirebaseAdminApp ,
1717} from 'firebase-admin/app'
18+ import { markRaw } from 'vue'
1819import type { NuxtVueFireAppCheckOptions } from './runtime/app-check'
1920
2021export interface VueFireNuxtModuleOptions {
@@ -94,9 +95,10 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
9495 new URL ( '../templates' , import . meta. url )
9596 )
9697
98+ // TODO: I don't think the appConfig is the right place to store these as it makes things reactive
9799 // Let plugins and the user access the firebase config within the app
98- nuxt . options . appConfig . firebaseConfig = options . config
99- nuxt . options . appConfig . vuefireOptions = options
100+ nuxt . options . appConfig . firebaseConfig = markRaw ( options . config )
101+ nuxt . options . appConfig . vuefireOptions = markRaw ( options )
100102
101103 // nuxt.options.build.transpile.push(templatesDir)
102104 nuxt . options . build . transpile . push ( runtimeDir )
@@ -114,7 +116,7 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
114116 '[VueFire]: Missing firebase "admin" config. Provide an "admin" option to the VueFire module options. This is necessary to use the auth or app-check module.'
115117 )
116118 }
117- nuxt . options . appConfig . firebaseAdmin = options . admin
119+ nuxt . options . appConfig . firebaseAdmin = markRaw ( options . admin )
118120 }
119121 }
120122
@@ -127,11 +129,24 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
127129
128130 // this allows us to the order of the plugins
129131 nuxt . hook ( 'modules:done' , ( ) => {
130- addPlugin ( resolve ( runtimeDir , 'auth/plugin.client' ) )
131- // must be added after the admin module to use the admin app
132- addPlugin ( resolve ( runtimeDir , 'auth/plugin.server' ) )
132+ if ( options . auth ) {
133+ addPlugin ( resolve ( runtimeDir , 'auth/plugin.client' ) )
134+ // must be added after the admin module to use the admin app
135+ addPlugin ( resolve ( runtimeDir , 'auth/plugin.server' ) )
136+ }
133137
134- addPlugin ( resolve ( runtimeDir , 'admin/plugin.server' ) )
138+ if ( options . admin ) {
139+ if ( ! nuxt . options . ssr ) {
140+ console . warn (
141+ '[VueFire]: The "admin" option is only used during SSR. You should reenable ssr to use it.'
142+ )
143+ }
144+ addPlugin ( resolve ( runtimeDir , 'admin/plugin.server' ) )
145+ }
146+
147+ if ( options . appCheck ) {
148+ addPlugin ( resolve ( runtimeDir , 'app-check/plugin' ) )
149+ }
135150
136151 // plugin are added in reverse order
137152 addPluginTemplate ( {
@@ -142,6 +157,8 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
142157 ssr : nuxt . options . ssr ,
143158 } ,
144159 } )
160+
161+ // adds the firebase app to each application
145162 addPlugin ( resolve ( runtimeDir , 'app/plugin' ) )
146163 } )
147164 } ,
@@ -158,6 +175,7 @@ declare module '@nuxt/schema' {
158175 export interface AppConfig {
159176 /**
160177 * Firebase config to initialize the app.
178+ * @internal
161179 */
162180 firebaseConfig : FirebaseOptions
163181
@@ -169,6 +187,7 @@ declare module '@nuxt/schema' {
169187
170188 /**
171189 * Firebase Admin options passed to VueFire module. Only available on the server.
190+ * @internal
172191 */
173192 firebaseAdmin ?: {
174193 config : Omit < AppOptions , 'credential' >
0 commit comments