In this tutorial, we will learn how to use Next.js 13 by building a project from scratch. Next.js is a React framework that allows you to build server-side rendered and static websites with ease. With the latest version 13, Next.js has introduced several new features and improvements that make the development process even smoother.
Before we begin, make sure you have Node.js installed on your machine. If not, you can download and install it from the official Node.js website.
Let’s start by creating a new Next.js project. Open your terminal and run the following commands:
npx create-next-app@13 my-next-project
cd my-next-project
npm run dev
This will create a new Next.js project in a folder called my-next-project
and start the development server. You can now open your browser and navigate to http://localhost:3000
to see the default Next.js homepage.
Next, let’s create a new page for our project. Inside the pages
directory, create a new file called index.js
and add the following code:
import React from 'react';
const HomePage = () => {
return (
<div>
<h1>Welcome to my Next.js 13 project!</h1>
</div>
);
};
export default HomePage;
Now, if you navigate to http://localhost:3000
, you should see the new homepage we just created.
Next, let’s add some styles to our project using Tailwind CSS. First, install Tailwind CSS and its dependencies by running the following command in your terminal:
npm install tailwindcss@latest postcss@latest autoprefixer@latest
Next, create a new file called styles/globals.css
and add the following code:
@tailwind base;
@tailwind components;
@tailwind utilities;
Now, import the globals.css
file in the _app.js
file located in the pages
directory:
import '../styles/globals.css';
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />;
}
export default MyApp;
Now, you can start adding Tailwind CSS styles to your components and pages.
Finally, let’s deploy our project to Vercel. First, sign up for a Vercel account if you don’t already have one. Next, link your Vercel account to your GitHub repository, where your Next.js project is hosted. Finally, run the following command in your terminal:
npm run build
This will create a production build of your project. Next, run the following command to deploy your project to Vercel:
vercel --prod
Follow the prompts to deploy your project to Vercel. Once the deployment is complete, you will receive a URL where your project is hosted.
Congratulations! You have successfully learned how to build a project with Next.js 13. Now you can continue exploring the features and capabilities of Next.js to build your own custom projects.
I just screenshot 21:52. That tells me EVERYTHING I need to know haha. Dude amazing explanation. I was fighting moving to 13.4 next so hard now I'm fucking excited to hop in!
If I wanted to deploy this project to prod, what service would I use?
Nice video man
I like how he explains content generally but the pace of his videos are way too fast. Completing this tutorial will definitely take longer than the runtime if you're learning for the first time, for anyone who is curious.
That "use server" string is very odd. Is that some native javascript mechanism?
I like this. Tanks for the upload. it is getting me up to speed fast 🙂
This video was amazing! Thank you so much for the great content and breaking things down the way that you do!
Thank you from Ukraine =)
Great tutorial, but you rushed too much through the video
Thank you kyle, best explanation now next one of my favorites frameworks
was that teaching or reminding???
You explain is very clearly! Thank you so much!
Hello! What application are using to create this video? Is amazing!
Just wow. Can this be used with springboot application running on postgresql. Can prisma be used
This was not a NextJS training at all, but a general training of something else that was not suitable at all
@latest is 14 now 😀
Everything is awesome except that my laptop is burning XD
Hey Kyle, now that next.js is on version 14, do you still need to create the db singleton function?
thanks for the tutorial!
What would you do if the action for toggleTodo was throw an error or just failed with some db connections error ? The client shows true but the db think it’s false ?