Skip to content
Discussion options

You must be logged in to vote

You can initialize Firebase directly inside the service-worker file. The current FCM documentation shows exactly that: initializeApp({...firebaseConfig}) in the worker.

Passing config through query parameters is therefore not a Firebase or service-worker lifecycle requirement. It is a deployment choice that lets an unbundled/static worker receive environment-specific values at registration time. A file placed in Next.js public/ is served as-is, so it does not automatically share imports or build-time variables with your application bundle. If you bundle the worker, importing/injecting the config at build time is another valid approach.

Firebase can also be used with Next.js without a serv…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by phoneticallySAARTHaK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants