Cookies in NextJS: Easy To Learn & Super Useful!

preview_player
Показать описание
Cookies in NextJS Middleware are super simple and yet prove to be useful in a variety of situations. Let's take a look at how to use cookies in nextjs middleware!

Don't ask me what the heck that thing in the thumbnail is haha

Thanks for watching and have fun implementing this knowledge into your own projects!
Рекомендации по теме
Комментарии
Автор

0:45 middleware
5:10 get cookie
8:02 get all cookies
9:58 delete cookie
10:43 set cookie
12:43 headers
15:20 eg use case

charlottetowelll
Автор

7:18 as of January 2023, this Nextjs' method actually does work.

kirkrepository
Автор

i don’t get why the cookie can’t be fully deleted. it’s able to be mutated but not deleted?? why?

samifouad
Автор

Josh any chance on you making a video on how to setup a cookie consent in next? There is very few information about how to make your website grpd ready

matheuscampos
Автор

Do you have something on combining for example (highly appreciated) next-intl and next-auth, and just in general how to combine different middleware especially in nextjs 13.2+ ?

andriisukhariev
Автор

Since you're in germany too, could you show how to handle cookie consent and/or google tag manager in nextjs 13? Thanks for all you do!

maxwolf
Автор

is it possible to redirect user to the login page if a cookie let's say called 'redirect' exists?

christiandinata
Автор

handling requests and responses is a MESS in NextJs

xxapoloxx
Автор

crazy to me how next.js docs are giving wrong syntaxe, just wow, thanks for the vid josh

hatem.tommy.lamine
Автор

IDK what it is about your videos I love, But I gotta say you're rocking!!! Keep on the Good job bro 😘

riveto_ir
Автор

can't we set cookie in api folder instead of middleware

saireddy-tk
Автор

Around about 10m 30s the auth cookie is deleted in the middleware and yet remains in the browser and I assume so would the cookie value if Josh hadn't manually deleted it. Why is this and does it mean the user will still possess any authorisation provided by the 'deleted' cookie?

John-eqcd
Автор

And how could you access the cookie from the api/route?
greetings!!

julian
Автор

cookies() destroys ssg for entire project?

en_kratia
Автор

My current set up is my server stored an access token and refresh token in cookies on the BE.

My API will return the jwt access token on login and then I’m using js-cookie to save the cookie, then I can use that cookie in middleware.

Lots of cookies 🍪 is js-cookie a fine library for creating the cookie on the client side?

tylerolthuizen
Автор

bro the method of the docs works for me !

EPIC-evlx
Автор

Time to hook it with an express api and jwt;
Thanks buddy.

raymondmichael
Автор

Anyone know how to remove cookies from the headers, for example when creating a sign out function? I'm using the clear() method on NextRequest.cookies, and getting an error saying that it's not a function

andreipene
Автор

Mine came as an object so yes they were correct

elozinoovedhe
Автор

Great video...Josh! Can you share your github

developer_
visit shbcf.ru