From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Setup authentication flow using JOSE and JWT - Next.js Tutorial
From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance
Setup authentication flow using JOSE and JWT
In this lecture, we will set up the authentication flow using Jose with JWT. For that, I will install the dependency for Jose and JWT. So I'll open the terminal. And let me just say npm i jose jsonweb token, enter. All right, now we will need a secret key for encoding and decoding the token. So I will open the dotenv file and add the secret key for JWT by saying JWT underscore secret JWT secret. Now here I have used a simple string as the secret value which you can generate or type manually. However, we ideally have a 32 character value. So I have typed 32 characters and you can get this exact value from the source code attached. Now I will open the utils.js file and create the function which will generate the JWT token. And for creating a token, we will create an instance of the SignJWT class which is a part of the Jose library. And this class will actually return the JSON web token in the instance. But this process is going to be asynchronous. So I will create the asynchronous…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Download courses and learn on the go
Watch courses on your mobile device without an internet connection. Download courses using your iOS or Android LinkedIn Learning app.
Contents
-
-
Introduction4m 10s
-
Next.js in spite of React1m 38s
-
RQ: Next.js in spite of React3m 32s
-
Creating first project4m 2s
-
RQ: Creating first project2m 16s
-
Project structure2m 59s
-
RQ: Project structure1m 33s
-
Pages Router vs. App Router1m 40s
-
RQ: Pages Router vs. App Router54s
-
React (client side) vs. Next.js (server side)1m 19s
-
-
-
(Locked)
Defining routes2m 53s
-
(Locked)
Nested routes1m 28s
-
(Locked)
Linking pages2m 48s
-
(Locked)
Understanding global layout3m 8s
-
(Locked)
Creating global header component3m 9s
-
(Locked)
The import alias2m 4s
-
(Locked)
Configuring favicon using image files1m 40s
-
(Locked)
Configuring favicon using code2m 31s
-
(Locked)
Component basics2m 48s
-
(Locked)
Component: Autooptimization feature1m 48s
-
(Locked)
RQ: Component—autooptimization feature1m 10s
-
(Locked)
Styling: Global CSS and CSS modules4m 36s
-
(Locked)
RQ: Styling—global CSS and CSS modules1m 50s
-
(Locked)
React server component vs. client component5m 18s
-
(Locked)
RQ: React server component vs. client component1m 24s
-
(Locked)
Error page3m 22s
-
(Locked)
Not found page1m 23s
-
(Locked)
Dynamic routes and route params4m 34s
-
(Locked)
Making API calls in Next.js4m 21s
-
(Locked)
Asynchronous server components3m 51s
-
(Locked)
RQ: Asynchronous server components1m 24s
-
(Locked)
Implementing loading component3m 7s
-
(Locked)
-
-
(Locked)
Introduction1m 10s
-
(Locked)
Setting up database with better-sqlite32m 30s
-
(Locked)
Table creation and adding data3m 53s
-
(Locked)
Rendering data in next app3m 41s
-
(Locked)
Configuring dynamic routes for products3m
-
(Locked)
Refactoring the code structure2m 24s
-
(Locked)
Manually configuring Tailwind CSS4m
-
(Locked)
Creating add product interface10m 21s
-
(Locked)
Handling form submission with server action4m 21s
-
(Locked)
Executing query and redirecting with redirect()3m 28s
-
(Locked)
Creating products grid interface6m 2s
-
(Locked)
RQ: Creating products grid interface48s
-
(Locked)
Implementing delete product feature3m 59s
-
(Locked)
Implementing edit functionality4m 39s
-
(Locked)
-
-
(Locked)
Understanding caching in Next.js3m 19s
-
(Locked)
RQ: Understanding caching in Next.js2m 23s
-
(Locked)
Unexpected behaviour in project build3m 21s
-
(Locked)
RQ: Unexpected behaviour in project build1m 35s
-
(Locked)
Static to dynamic: Cache control2m 28s
-
(Locked)
RQ: Static to dynamic—cache control1m 6s
-
(Locked)
Time-based cache control5m 3s
-
(Locked)
RQ: Time-based cache control2m 3s
-
(Locked)
Path-based revalidation3m 59s
-
(Locked)
RQ: Path-based revalidation1m 31s
-
(Locked)
Revalidating with revalidateTag()3m 28s
-
(Locked)
RQ: Revalidating with revalidateTag()1m 50s
-
(Locked)
-
-
(Locked)
Introduction to Pages Router3m 25s
-
(Locked)
RQ: Introduction to Pages Router1m 8s
-
(Locked)
Routing with Pages Router4m 17s
-
(Locked)
Extracting the slug from dynamic path1m 52s
-
(Locked)
Catch-all segments in Pages Router3m 32s
-
(Locked)
RQ: Catch-all segments in Pages Router1m 7s
-
(Locked)
Adding global interface2m 2s
-
(Locked)
Linking and navigation2m 11s
-
(Locked)
-
-
(Locked)
Introduction to Prisma1m 21s
-
(Locked)
RQ: Introduction to Prisma1m 38s
-
(Locked)
Setting up Prisma4m 9s
-
(Locked)
Creating Prisma client1m 42s
-
(Locked)
Inserting data using create()4m 29s
-
(Locked)
Inserting data using createMany()3m 6s
-
(Locked)
All possibilities of record deletion - delete() and deleteMany()4m
-
(Locked)
Fetching data with Prisma3m 22s
-
(Locked)
Updating records with Prisma3m 35s
-
(Locked)
The upsert() method2m 28s
-
(Locked)
-
-
(Locked)
Introduction2m 36s
-
(Locked)
Project creation2m 41s
-
(Locked)
Creating sidebar component3m 34s
-
(Locked)
Working on sidebar3m 46s
-
(Locked)
Combining utility classes with @apply3m 54s
-
(Locked)
RQ: @layer and @apply—combining utility classes1m 37s
-
(Locked)
Styling the sidebar4m 56s
-
(Locked)
Adding icons to the sidebar3m 3s
-
(Locked)
Creating users page5m 43s
-
(Locked)
Creating add users form7m 8s
-
(Locked)
Implementing component-based architecture6m 34s
-
(Locked)
Creating button and input components4m 16s
-
(Locked)
Refactoring code structure2m 40s
-
(Locked)
Database creation2m 30s
-
(Locked)
Adding users with server action4m
-
(Locked)
Implementing hashing3m 19s
-
(Locked)
RQ: Implementing hashing2m 4s
-
(Locked)
Validating user creation3m 44s
-
(Locked)
Rendering users in the table5m 44s
-
(Locked)
Creating edit user page3m 33s
-
(Locked)
Dynamic default values for edit2m 45s
-
(Locked)
Updating user data3m 43s
-
(Locked)
Deleting user3m 41s
-
(Locked)
Creating delete confirmation popup4m 17s
-
(Locked)
Enabling confirmation popup5m 32s
-
(Locked)
Deleting user by confirmation popup2m 24s
-
(Locked)
Creating product type page4m 39s
-
(Locked)
Creating add product type page3m 36s
-
(Locked)
Adding product types and products models into the schema3m 37s
-
(Locked)
RQ: Adding models in the schema—product type and product1m 6s
-
(Locked)
Adding product type using server action4m 26s
-
(Locked)
Rendering product types into the table2m
-
(Locked)
Creating edit product type page3m 19s
-
(Locked)
Dynamic default values for product type2m 33s
-
(Locked)
Updating product type with server action2m 39s
-
(Locked)
Deleting product type with server action1m 50s
-
(Locked)
Creating products page3m 46s
-
(Locked)
Creating products interface for listing4m 50s
-
(Locked)
Creating add product page2m 57s
-
(Locked)
Completing add products form2m 55s
-
(Locked)
Creating switch component5m 10s
-
(Locked)
Creating file input component6m 17s
-
(Locked)
Rendering dynamic product types data in add product page2m 12s
-
(Locked)
Creating server action for adding products3m 4s
-
(Locked)
Implementing image storage functionality5m 53s
-
(Locked)
Completing add product functionality4m 13s
-
(Locked)
Rendering dynamic data in products table3m 53s
-
(Locked)
Creating edit product page3m 13s
-
(Locked)
Dynamic default values for product3m 44s
-
(Locked)
Render default values in switch and file input2m 39s
-
(Locked)
Updating product with server action5m 14s
-
(Locked)
RQ: Updating product with server action1m 39s
-
(Locked)
Deleting product with server action2m 3s
-
(Locked)
-
-
(Locked)
Initiating client section1m 53s
-
(Locked)
Creating header component5m 20s
-
(Locked)
Implementing search bar2m 16s
-
(Locked)
Joining Tailwind classes with ideal approach2m 34s
-
(Locked)
RQ: Joining Tailwind classes with ideal approach2m 38s
-
(Locked)
Adding profile drop-down4m 31s
-
(Locked)
useRef() hook4m 42s
-
(Locked)
Close profile drop-down menu on outside click3m 2s
-
(Locked)
RQ: Close profile drop-down menu on outside click2m 36s
-
(Locked)
Creating input component1m 54s
-
(Locked)
Creating home page2m 34s
-
(Locked)
Creating filters section6m 15s
-
(Locked)
Creating custom accordion component10m 58s
-
(Locked)
RQ: Creating custom accordion component1m 37s
-
(Locked)
Completing custom accordion component4m 35s
-
(Locked)
Continue on filter section3m 2s
-
(Locked)
Creating price range slider component4m 39s
-
(Locked)
Creating product card component8m 17s
-
(Locked)
Completing product card component2m 47s
-
(Locked)
Creating button component1m 44s
-
(Locked)
API creation for product listing3m 59s
-
(Locked)
Dynamic product rendering using server action7m 12s
-
(Locked)
API creation for fetching product types1m 41s
-
(Locked)
Dynamic product type rendering using API2m 28s
-
(Locked)
Set filter values into the search params4m 29s
-
(Locked)
Modifying products API to apply filters5m 35s
-
(Locked)
Filter functionality on client side3m 44s
-
(Locked)
Search filter functionality4m 31s
-
(Locked)
Creating product page6m 38s
-
(Locked)
Completing product page3m 21s
-
(Locked)
API creation for fetching a product by its ID2m 54s
-
(Locked)
Dynamic product details rendering using API3m 25s
-
(Locked)
Rendering products based on status2m 42s
-
(Locked)
Creating cart page3m 24s
-
(Locked)
Rendering cart item card6m 22s
-
(Locked)
Completing the cart UI4m 55s
-
(Locked)
Creating context for handling products1m 50s
-
(Locked)
RQ: Creating context for handling products1m 28s
-
(Locked)
Implement cart functionalities8m 4s
-
(Locked)
Making cart page dynamic2m 54s
-
(Locked)
Enabling quantity selection3m 45s
-
(Locked)
Finishing dynamic cart page5m 6s
-
(Locked)
-
-
(Locked)
Creating login page5m 52s
-
(Locked)
Introduction of JOSE and JWT1m 53s
-
(Locked)
Setup authentication flow using JOSE and JWT8m 49s
-
(Locked)
Create server action for login3m 13s
-
(Locked)
Cookie-based authentication4m 56s
-
(Locked)
RQ: Cookie-based authentication1m 14s
-
(Locked)
Handling private and public routes using middleware5m 3s
-
(Locked)
Fetching authenticated user data3m 7s
-
(Locked)
Implementing logout with server action5m 18s
-
(Locked)
Authenticate all the server actions of admin section2m 50s
-
(Locked)
Creating the authentication routes on the client section3m 28s
-
(Locked)
Creating interface for authentication routes5m 47s
-
(Locked)
Creating buyer table in the database1m 55s
-
(Locked)
Creating sign-up API3m 52s
-
(Locked)
Testing sign-up API using Postman3m 37s
-
(Locked)
Creating login API2m 56s
-
(Locked)
Testing the login API using Postman1m 34s
-
(Locked)
Implementing sign-up functionality in the client section7m 19s
-
(Locked)
Implementing customer login functionality3m 59s
-
(Locked)
API to fetch unique customer data4m 18s
-
(Locked)
Fetching customer data using API in the client section5m 35s
-
(Locked)
Logout functionality in the client section2m 8s
-
(Locked)
-
-
(Locked)
Introduction2m 16s
-
(Locked)
RQ: Introduction2m 17s
-
(Locked)
Basic configurations of Stripe4m 19s
-
(Locked)
Rendering Stripe's embedded checkout form8m 11s
-
(Locked)
Creating checkout session dynamically6m 44s
-
(Locked)
Creating payment status page7m 23s
-
(Locked)
Creating sales and transaction table in database4m 51s
-
(Locked)
API to update database after successful checkout6m 5s
-
(Locked)
Testing the checkout API using Postman3m 57s
-
(Locked)
Integrating checkout API in the client section2m 55s
-
(Locked)
Creating buyer master section3m 18s
-
(Locked)
Fetching buyers list using server action2m 40s
-
(Locked)
-
-
(Locked)
Introduction2m 21s
-
(Locked)
Preparing customers and buyers report3m 13s
-
(Locked)
Rendering customers and buyers report3m 32s
-
(Locked)
Preparing total revenue report2m 2s
-
(Locked)
Preparing recent order report7m 46s
-
(Locked)
Creating purchased products modal3m 51s
-
(Locked)
Fetching purchased products in modal1m 41s
-
(Locked)
Render products in the purchased products table2m 24s
-
(Locked)
Implementing chart using Recharts5m 51s
-
(Locked)
Preparing sales report using chart4m 42s
-
(Locked)
Rendering sales chart with dynamic values2m 35s
-
(Locked)
Preparing customers report using chart4m 35s
-
(Locked)
Creating chart section component1m 34s
-
(Locked)
-
-
(Locked)
Introduction3m 55s
-
(Locked)
RQ: Introduction1m 41s
-
(Locked)
Introduction to CI/CD2m 38s
-
(Locked)
RQ: Introduction to CI/CD1m 5s
-
(Locked)
GitHub integration6m 4s
-
(Locked)
RQ: GitHub integration1m 38s
-
(Locked)
Database migration from SQLite to MySQL5m 22s
-
(Locked)
Link the MySQL database to admin application4m 22s
-
(Locked)
Deploying admin app on Vercel7m 43s
-
(Locked)
Deploying client app on Vercel6m 39s
-
(Locked)