This is a starter project for those who want to build a fullstack app with Next.js on the front-end and Nest.js on the back-end. It helps you get started with an already built session based authentication using Firebase Auth service.
- Session based authentication
- Sign In / Sign Up
- Email/Password auth
- Social auth (Google/Facebook)
Install the necessary packages with npm
cd client; npm i
cd ../server; npm i
To run this project, you will need to create a .env
file on both the client
and server
directories with the following variables:
NEXT_PUBLIC_FIREBASE_API_KEY
: firebase api keyNEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
: firebase auth domainNEXT_PUBLIC_FIREBASE_PROJECT_ID
: firebase project idNEXT_PUBLIC_FIREBASE_STORAGE_BUCKET
: firebase storage bucketNEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID
: firebase sender idNEXT_PUBLIC_FIREBASE_APP_ID
: firebase app idNEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
: firebase measurement id
(You get these from Firebase once you create a project)
NEXT_PUBLIC_API_URL
: your api url (will behttp://localhost:3001
by default if you're running the api locally)
FIREBASE_PRIVATE_KEY
: your firebase Private KeyFIREBASE_PROJECT_ID
: firebase project id (same as above)FIREBASE_CLIENT_EMAIL
: your firebase client emailDB_URL
: yourpostgres
database url (you can change your db type if you don't want to usepostgres
in theserver/src/app.module.ts
file)
Database synchronization is set to true
for development, make sure to set it to false
in production (server/src/app.module.ts
)
Start the server
cd server/
npm run start:dev
Start client
cd ../client/
npm run dev
Getting the user session:
function App() {
const session = useSession();
return <Component />
}
async function App() {
const session = await getServerSession();
return <Component />
}