Supabase Auth in Next.js 13 Server Components and Route Handlers

  Рет қаралды 10,447

makrdev

makrdev

Күн бұрын

In this video tutorial, we will be learning about building a web application with ‪@Supabase‬ and Next.js 13, using Supabase's powerful built-in authentication system. We will start by installing necessary packages, setting environment variables, and creating three different Supabase Clients: server, browser, and middleware - each used for specific purposes.
We will also create components for Supabase and auth logic and demonstrate how to use context providers to create a single instance of the Supabase client for our entire application.
By the end of this video, you will have a cutting-edge application with authentication systems implemented in seconds. So, join us and take your web development skills to the next level!
- timestamps -
00:00 - Intro
00:25 - Application Walkthrough & Setup
03:17 - Creating Supabase Clients
07:54 - Root Layout
08:52 - Supabase Provider
21:18 - Components Walkthrough
25:05 - Protecting Routes
Source Code: github.com/batuhanbilginn/sup...
Learn more: makr.dev
#supabase #typescript #development #developer

Пікірлер: 53
@adal7769
@adal7769 Жыл бұрын
thanks for the video !! also i agree with the font-size comment, but the video was very helpful!
@makrdev
@makrdev Жыл бұрын
I’m glad you liked it. The font size issue will be fixed anymore, thank you for your feedback 👍
@tomasgonzalez1757
@tomasgonzalez1757 Жыл бұрын
this is far better explained than the supabase docs. Thank you!!!!! great content
@tomasgonzalez1757
@tomasgonzalez1757 Жыл бұрын
btw, createServerComponentSupabaseClient has been replaced with createServerComponentClient
@makrdev
@makrdev Жыл бұрын
Glad it was helpful!
@yashpancholi3706
@yashpancholi3706 4 ай бұрын
This worked for me Thanks for the help!
@KislayRaj
@KislayRaj Жыл бұрын
Super helpful and working! Thanks for the video!!
@makrdev
@makrdev Жыл бұрын
I’m glad you liked it 👍
@user-df5zx1ft6n
@user-df5zx1ft6n Жыл бұрын
Great explanation. This is very helpful. You have saved me hours. Thanks! Please post more videos on next JS. I feel with new updates in Next 13 it's hard to keep up with them.
@makrdev
@makrdev Жыл бұрын
Thank you so much 😊 I’ll post it 🤞
@giroda
@giroda 11 ай бұрын
Very well prepared, actually the explanation way better than other ones, step by step, not like pasting from the other monitor and passing without giving any word about why, that is the most important!
@cidhighwind8590
@cidhighwind8590 Жыл бұрын
Not even 4 months in and create the createServerComponentSupabaseClient function (as well as many others im sure) has been replaced with createServerComponentClient in the Next.js Auth Helpers. This change was made in version 0.7.x of the Auth Helpers. For anyone who wants to know.
@makrdev
@makrdev Жыл бұрын
Yeah lot's of changed after this video. I'll be waiting a little bit more before creating a new one.
@shawnyeo7086
@shawnyeo7086 8 ай бұрын
they changed again with SSR fucking ridiculous
@beauhawkinson1758
@beauhawkinson1758 Жыл бұрын
This was a wonderful implementation!
@makrdev
@makrdev Жыл бұрын
Thank you!
@UmairQamer
@UmairQamer Жыл бұрын
You are doing an amazing job man. Just a little suggestion - The intro music was too loud compared to your voice
@makrdev
@makrdev Жыл бұрын
Upps, thanks for the feedback bro. I didn’t realize it. I’ll fix it. 🤞
@8koi245
@8koi245 Жыл бұрын
Holy thanks for the warning
@appstuff6565
@appstuff6565 10 ай бұрын
Hey makrdev! Thanks for this. Just started and I read the description and it cleared a lot of things that im looking for before starting the video. I'll get back to you how it went! Subbed.
@appstuff6565
@appstuff6565 10 ай бұрын
update: many skipped steps for beginners like me. like where did the utils folder come from etc etc. Also, please tone up a bit because when the music/sfx plays it blasts my ears. Thanks. Dony worry, Still subbed.
@appstuff6565
@appstuff6565 10 ай бұрын
unfortunately i had to stop within 5 minutes of this. Maybe next time.
@waleedtahir9933
@waleedtahir9933 Жыл бұрын
For Those who Are Saying Font Size Issue : 1 : Use Laptop 2 : Watch Video in 1440 quality 3 : In mobile use Zoom Mode youtube introduced it recently BTW Thanks Man You are a life saver Please Continue these helpful videos 😍😍😎😎 Lots of love from Pakistan
@makrdev
@makrdev Жыл бұрын
Thank you so much bro!
@michaelholmes924
@michaelholmes924 Жыл бұрын
Cool to know this is possible! So client components auth will work the old way? I can still use supabase client as before?
@makrdev
@makrdev Жыл бұрын
They are constantly change the way it works. I’ll need to make another video probably in the near future.
@doumams347
@doumams347 Жыл бұрын
I like the project and how you structured it ! My problem is that I receive an error saying "./node_modules/node-fetch/lib/index.js Module not found: Can't resolve 'encoding' in 'C:\Users\Bingo\Documents\Projets personnels ext_supabase_auth ode_modules ode-fetch\lib'" And i really don't know how to fix it
@makrdev
@makrdev Жыл бұрын
It’s a known problem caused by Supabase. They are currently working on a fix for this issue however it’s not a critical thing so you can safely ignore this error. Also, you can install ‘encoding’ package as a devDependency to fix it manually.
@panduananto7179
@panduananto7179 Жыл бұрын
Hello, can you please try, with this setup doing dynamic routing with the new generateStaticParams function? I can't get it to work
@makrdev
@makrdev Жыл бұрын
I’ll post a video today, which contains dynamic routing 🤞
@justisabelll
@justisabelll 11 ай бұрын
what camera do you use? this video looks great.
@makrdev
@makrdev 10 ай бұрын
Sony A73 👍
@tomasgonzalez1757
@tomasgonzalez1757 Жыл бұрын
​ @makrdev i have a question, have you tried using Supabase using this Auth Setup but managin the rest of the data with Prisma? i feel that it can be done since i can send the session data to the DB through Prisma, and avoid linking Prisma with the users schema that seems to be the step that brings most of the problems to users
@makrdev
@makrdev Жыл бұрын
I haven’t tried it but the problem you need to solve is authorization layer. I don’t like making things complicated. What is the advantage of using Prisma here?
@shakti_pattanaik01
@shakti_pattanaik01 Жыл бұрын
Hi Mark, thank you for the video. I have a follow up question. How to create a protected and unprotected route in this type of settings? suppose I want to create a protected routed '/profile' and unprotected route '/about', how do I achieve that?
@makrdev
@makrdev Жыл бұрын
You can create an array of the routes you want to protect. In middleware, check if the route is in that list or not. Redirect user based on the condition.
@shakti_pattanaik01
@shakti_pattanaik01 Жыл бұрын
@@makrdev thank you. Will try this. Please keep on posting more videos on nextjs+supabase 👍🏻
@olekkalashnyk4771
@olekkalashnyk4771 Жыл бұрын
I also like to use supabase and directus, but I'm having problems with self-deploy directus, I can't figure out how to deploy and create a production and development server myself. If you could help - record a video or personally I would be very grateful to you)
@makrdev
@makrdev Жыл бұрын
You can deploy Directus with easily with Railway. You just need to connect your Github repo with it. Also, you can create snapshot for your local environment. If you change your schema on local you can always push the difference with same method. There is a great article about this: docs.directus.io/cookbook/migration/node.html#migrate-your-data-model-with-node-js I'll create tutorials on this topic soon. So, stay tuned. Also, you can always reach out to me from my Twitter.
@emiliano2471
@emiliano2471 Жыл бұрын
how do you remove the access token from the URL after redirecting?
@makrdev
@makrdev Жыл бұрын
Just replace the URL with router.replace()
@dheerajs2838
@dheerajs2838 Жыл бұрын
you need to increase the font size man .. very hard to see
@makrdev
@makrdev Жыл бұрын
Yeap, I increased it on latest videos. Thanks for the feedback 👍
@skverskk
@skverskk Жыл бұрын
Can't read from your video. The fonts are so-so small, that it's nearly impossible to watch
@makrdev
@makrdev Жыл бұрын
Thank you for the feedback! I’ll increase the font size.
@skverskk
@skverskk Жыл бұрын
@@makrdev Thank you
@imalizardperson9987
@imalizardperson9987 10 ай бұрын
👎
@JoelLawler
@JoelLawler Жыл бұрын
Great explanation. Thank you for doing these videos. They are super helpful. I am running into an issue that I can't seem to resolve. I am getting this error: ./utils/supabase-server.ts ReactServerComponentsError: You're importing a component that needs server-only. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component. ,-[/Users/joellawler/Projects/JavaScript/ICDashboardUI/ui/utils/supabase-server.ts:1:1] 1 | import { createServerComponentSupabaseClient } from "@supabase/auth-helpers-nextjs"; 2 | import { cookies, headers } from "next/headers"; 3 | import "server-only"; : ^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | import type { Database } from "../types/supabase"; `---- One of these is marked as a client entry with "use client": ./utils/supabase-server.ts ./components/providers/supabase-provider.tsx ./components/providers/supabase-auth-provider.tsx ./app/(auth)/login/login-form.tsx Grateful for your thoughts on this.
@makrdev
@makrdev Жыл бұрын
Looks like you are trying to import Supabase Server instance into a client component. In client components you should use the one you created in useSupabase hook.
@JoelLawler
@JoelLawler Жыл бұрын
@@makrdev Thank you.
@user-qz5yx3hk6r
@user-qz5yx3hk6r 5 ай бұрын
I get: {code: '42P01', details: null, hint: null, message: 'relation "public.profiles" does not exist'}
@makrdev
@makrdev 5 ай бұрын
Yeah, first you need to create profiles table. You can use the auth starter from SQL to create your profiles table.
How to create background jobs with Next.js and Inngest
23:33
makrdev
Рет қаралды 3,3 М.
Laravel Dusk: painless browser automation
20:49
Aaron Francis
Рет қаралды 14 М.
Double Stacked Pizza @Lionfield @ChefRush
00:33
albert_cancook
Рет қаралды 114 МЛН
World’s Largest Jello Pool
01:00
Mark Rober
Рет қаралды 104 МЛН
ОБЯЗАТЕЛЬНО СОВЕРШАЙТЕ ДОБРО!❤❤❤
00:45
Next.js Server Actions...  5 awesome things you can do
7:51
Beyond Fireship
Рет қаралды 261 М.
Set up Google OAuth with Next.js using Next-Auth!
21:00
Build SaaS with Ethan
Рет қаралды 23 М.
Next 14 + React Query COMBO with Server Actions and RSC
9:49
developedbyed
Рет қаралды 96 М.
Power your next app with Clerk + Supabase
16:09
Clerk
Рет қаралды 12 М.
The Story of Next.js
12:13
uidotdev
Рет қаралды 559 М.
Next.js Server Component role base access with Supabase
19:48
Daily Web Coding
Рет қаралды 15 М.
React Server Components: A Comprehensive Breakdown
52:42
Theo - t3․gg
Рет қаралды 96 М.
Looks very comfortable. #leddisplay #ledscreen #ledwall #eagerled
0:19
LED Screen Factory-EagerLED
Рет қаралды 11 МЛН