Comprehensive NEXT.js 14 Course: Creating and Launching a Full Stack App with Firebase & TailwindCSS

Posted by


In this detailed tutorial, we will walk you through building and deploying a full stack app using NEXT.js 14, Firebase, and TailwindCSS. We will cover all the necessary steps to create a fully functional app, from setting up the project to deploying it to a live server.

Setting up the project
To start, make sure you have Node.js installed on your machine. You can check if Node.js is installed by running the following command in your terminal:

node -v

If Node.js is not installed, you can download it from the official website:

https://nodejs.org

Next, create a new directory for your project and navigate into it using the terminal. Run the following commands to create a new NEXT.js project:

npx create-next-app my-nextjs-project

Replace my-nextjs-project with the name of your project. This command will generate a new project with all the necessary files and dependencies.

Installing Firebase
Firebase is a platform developed by Google for creating mobile and web applications. It provides a number of services, including authentication, database, storage, and hosting. To use Firebase in our project, we need to install the Firebase SDK. Run the following command in your terminal to install Firebase:

npm install firebase

Creating a Firebase project
Next, we need to create a new Firebase project. Go to the Firebase console and sign in with your Google account. Click on the "Create a project" button and follow the instructions to create a new project.

Once the project is created, click on the "Web" option to add a web app to your project. Enter a name for your app and click on the "Register app" button. Firebase will generate a configuration object that we will use in our NEXT.js app.

Setting up Firebase in NEXT.js
Now that we have created a Firebase project, we need to set it up in our NEXT.js app. Create a new file called firebase.js in the lib directory of your project and add the following code:

import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';

const firebaseConfig = {
  apiKey: 'YOUR_API_KEY',
  authDomain: 'YOUR_AUTH_DOMAIN',
  projectId: 'YOUR_PROJECT_ID',
  storageBucket: 'YOUR_STORAGE_BUCKET',
  messagingSenderId: 'YOUR_MESSAGING_SENDER_ID',
  appId: 'YOUR_APP_ID',
};

if (!firebase.apps.length) {
  firebase.initializeApp(firebaseConfig);
}

export const auth = firebase.auth();
export const firestore = firebase.firestore();

Replace the placeholders (YOUR_API_KEY, YOUR_AUTH_DOMAIN, YOUR_PROJECT_ID, YOUR_STORAGE_BUCKET, YOUR_MESSAGING_SENDER_ID, YOUR_APP_ID) with the corresponding values from your Firebase project.

Creating a Firebase authentication service
To enable authentication in our app, we need to create a new service that handles user authentication using Firebase. Create a new file called auth.js in the lib directory and add the following code:

import { auth } from './firebase';

export const signInWithGoogle = () => {
  const provider = new firebase.auth.GoogleAuthProvider();
  return auth.signInWithPopup(provider);
};

export const signOut = () => auth.signOut();

export const onAuthStateChanged = (onChange) => auth.onAuthStateChanged(onChange);

This service provides functions for signing in with Google, signing out, and listening to changes in the user’s authentication state.

Building the app UI with TailwindCSS
TailwindCSS is a popular CSS framework that makes it easy to build responsive web designs. To use TailwindCSS in our project, we need to install it. Run the following command in your terminal:

npm install tailwindcss

Next, create a new file called tailwind.config.js in the root directory of your project and add the following code:

module.exports = {
  mode: 'jit',
  purge: ['./pages/**/*.{js,jsx}', './components/**/*.{js,jsx}'],
  darkMode: false, // or 'media' or 'class'
  theme: {
    extend: {},
  },
  variants: {
    extend: {},
  },
  plugins: [],
};

Now, we need to configure NEXT.js to work with TailwindCSS. Create a new file called postcss.config.js in the root directory and add the following code:

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};

Finally, we need to import TailwindCSS styles in our app. Open the styles/globals.css file and add the following code:

@tailwind base;
@tailwind components;
@tailwind utilities;

Deploying the app to Firebase Hosting
Now that we have built our app, it’s time to deploy it to Firebase Hosting. First, install the Firebase CLI by running the following command in your terminal:

npm install -g firebase-tools

Next, initialize Firebase Hosting by running the following command in your project directory:

firebase init hosting

Follow the on-screen instructions to set up Firebase Hosting for your project. Once Firebase Hosting is set up, you can deploy your app by running the following command:

firebase deploy --only hosting

After the deployment is complete, Firebase will provide you with a live URL where your app is hosted.

Congratulations! You have successfully built and deployed a full stack app using NEXT.js 14, Firebase, and TailwindCSS. I hope this tutorial has been helpful in guiding you through the process of creating a fully functional app.

0 0 votes
Article Rating

Leave a Reply

34 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@Smoljames
1 hour ago

Cheers for watching 💛 Get hired faster with a better resume @ https://www.hyr.sh

@reeeez
1 hour ago

nice video, really helpful. I was wondering what plugin you use to format your code. I am using prettier and i find its always removing parenthesis from my functional components and always putting nested elements onto one line..

@ehsanullahdehzad2723
1 hour ago

I have to be studgying for Math exam, but here I am watching this amazing video

@lightofeloah5919
1 hour ago

can you please do a real time chat app tutorial

@tahmidhasan7356
1 hour ago

Too many tailwind use is very ugly where you come to learn nextJs

@ST20246
1 hour ago

27:05

@baazigar5
1 hour ago

Is this course cover all the topics of nextjs?

@isabellariquetti2410
1 hour ago

1:20:00 in, and I want to share a few things I did to make my life easier so far:

1. In the layout file, I added the property `variable: "–font-fugaz-one",` to the Fugaz font. Then, in the Tailwind config file, I added this:
“`
fontFamily: {
fugaz: ['var(–font-fugaz-one)', 'cursive'],
},
“`
With this, I can apply the Fugaz font anywhere just by adding the class `font-fugaz`.

2. Another small improvement: I installed `classnames`. I get the point of just using string interpolation, but it's easier to make mistakes like that. Now, for conditional class usages, I just import `classnames` package and use it like this:
“`
import classnames from "classnames";
/* code /*
<MyComponent className={classnames("my-base-classes applied-in-all-cases", {
"conditional-class": conditionalVariable,
"another-conditional-class": conditionalVariable2,
})} />
“`
It's good to know how to do this the vanilla way, but after a few times, it gets tiring to repeat.

@weraldopolento7079
1 hour ago

i got a error of Firebase: Error (auth/invalid-credential). I double check my api's details and it is correct, but it still give me that error. sadge

@a13Banger
1 hour ago

Just a fantastic video. I am just now picking up NextJs and you really make this easier to pick up. You have great pacing, super relevant dialog, just real mastery on display and I think that translates to something that is very easy to absorb on this end, for me. Thanks for sharing!

@Omar_Al_Seddik
1 hour ago

Yay, a Firebase project! It's better than Supabase in every way, imo, but for some reason I don't see many YouTubers covering it. This is a breath of fresh air for me.

Dude, I made a full stack project with Firebase 4 years ago with the free plan and revisited it to find that it's still fully functional. It's crazy. Supabase pauses free databases after a single week of inactivity. You also get 5 free projects with Firebase, leaving room for you to leave 5 impressive fully functional full-stack projects on your portfolio without spending a single cent.

After trying out many of the alternatives recently, I've come to appreciate Firebase much more. Auth is extremely easy to implement, with mails, 2FA, no UI baggage, and ultra cheap pricing. The Firestore database is real-time by default, which is insane to me. You have to spend extra for that with other services and be prepared to write extra lines of code to mimic Firebase's real-time perfection. And oh boy did I get stuck sometimes trying to fix compatibility issues between libraries.

I have so much more to say in praise of Firebase, but you get the idea lol.

@FrontendNerd-lg3oh
1 hour ago

need more nodejs conternt

@francisc.t.2033
1 hour ago

Hi james, ive followed you for a while, currently learning your React vids, your javascript roadmap on the website also helped alot, looking forward for the other Chapters Notes, 🎉❤ you mean a lot to me, thanks

@caioba5862
1 hour ago

Thanks man, you just got a subscriber, loved your content. Your way to explain things worked beautifully to me.
I'm from Brazil and you'r video was the first that i understood all since the beggining

@LeudaKuria
1 hour ago

I love how you assume we know nothing and you explain everything. You continue like this you'll be the biggest coding channel. Please never stop explaining the way you do, and do more full projects. I'm not a follower. I am a disciple. Give us more coding Jesus!

@daynuxer
1 hour ago

Masyaallah Barakallah God Bless You

@johnnonamegibbon3580
1 hour ago

Bro, you are blowing up. Well done.

@nahyanrajput3588
1 hour ago

Bro if I've learnt html css js, so can I now just learn next.js with firebase. Will it be enough?!

@nazd5594
1 hour ago

Btw, have you tried React Router? I've learned that for simple routing but seems like Next.js replaces that and looks much simpler. Curious to hear what you think.

@reggieescobar2772
1 hour ago

But have you tried NuxtJs?

34
0
Would love your thoughts, please comment.x
()
x