Basic template for nuxt v3 with firebase authentication - with backend auth on service workers and cookie fallback. Service workers are only used on production to prevent bugs.
Make sure to install the dependencies:
# yarn
yarn install
# npm
npm install
# pnpm
pnpm install --shamefully-hoist
Replace environment variables specified in .env.example and copy file to .env
//.env
FIREBASE_API_KEY= YOUR API KEY
FIREBASE_AUTH_DOMAIN= YOUR AUTH DOMAIN
SERVICE_ACCOUNT= YOUR SERVICE ACCOUNT (stringified json)
Download service account from firebase console and put the json in .env file
Replace config to yours at /public/sw.js
// /public/sw.js
const app = firebase.initializeApp({
apiKey: YOUR API KEY,
authDomain: YOUR AUTH DOMAIN
});
Start the development server on http://localhost:3000
npm run dev
Build the application for production:
npm run build
Locally preview production build:
npm run preview
Checkout the deployment documentation for more information.