Next.js Explained: How cookies() uses AsyncLocalStorage

Ғылым және технология

Learn how the Node.js AsyncLocalStorage API plays a key part in the design of the cookies() function for the Next.js App Router.
◆ Learn Next.js: nextjs.org/learn
◆ Deploy your first project: vercel.com/templates/next.js/...
#vercel

Пікірлер: 24

  • @janglad9136
    @janglad91362 ай бұрын

    Would love more videos like this, explaining how Next works under the hood!

  • @KevinNYank
    @KevinNYank2 ай бұрын

    I like the intent with this type of video, but there’s quite a bit of assumed knowledge here that makes it hard to follow - especially if you’re not already deep in the App Router/RSC world. Things that were stumbling blocks for me: What is Bun and why are you using it? We’re reading cookies on the server, not the client (I know you mentioned Node.js, but this bears saying explicitly). There’s a circular dependency between the two modules, index and user, in this example; is this just to keep the demo simple, or would you structure these modules this way in the real world? Why is rendering an async operation?

  • @nicolasguillenc
    @nicolasguillenc2 ай бұрын

    That's cool! I like this format, thank you for making these videos

  • @leerob

    @leerob

    2 ай бұрын

    Glad you found it helpful!

  • @thisweekinreact
    @thisweekinreact2 ай бұрын

    Nice video AsyncLocalStorage is awesome 😃👌 Can't wait for it to be standardised in runtimes. AsyncContext is stage 2, wonder if it will move up soon.

  • @alexedev
    @alexedev2 ай бұрын

    nice, please create more in-depth videos like this

  • @soulessshoe
    @soulessshoe2 ай бұрын

    great series!

  • @kasper369
    @kasper3692 ай бұрын

    pretty neat stuff

  • @fayrouzadham4808
    @fayrouzadham48082 ай бұрын

    can we apply the same idea for params and searchParams instead of sending it as props to the page component in nextjs ?

  • @goldydog1
    @goldydog12 ай бұрын

    Awesome, so this would theoretically work with the pages router too in a next 12 app that doesn't have access to cookies yet?

  • @gumisirizaemmanuel2411
    @gumisirizaemmanuel24112 ай бұрын

    How do you properly handle localstorage in a next js app

  • @hazemabdennadher5379
    @hazemabdennadher53792 ай бұрын

    what vs code theme are you using

  • @EricSproles-yf4pc
    @EricSproles-yf4pc2 ай бұрын

    Can AsyncLocalStorage be used across Middleware and Server Components?

  • @rijkvanwel
    @rijkvanwel2 ай бұрын

    Can we use that API ourselves as well? To store contexty things like current language?

  • @user-tb4ig7qh9b

    @user-tb4ig7qh9b

    2 ай бұрын

    Yes it is already used in react native project as a cache

  • @user-tb4ig7qh9b

    @user-tb4ig7qh9b

    2 ай бұрын

    It is like built-in redis

  • @hongz1
    @hongz12 ай бұрын

    I still don’t get it the point of this clip. No idea about Bun, but I can response with cookie something like res.cookie(‘Name’, ‘John’) in express. So what’s the point of using nextjs?

  • @en_kratia
    @en_kratiaАй бұрын

    Use cookies() === bye bye SSG?

  • @yassinesafraoui
    @yassinesafraoui2 ай бұрын

    Wouldn't that be weird if you run Nextjs on a lambda? For example if the user logged in and didn't use the app for some time and the lambda was shut down, well he simply lost his session I suppose if you used cookies to store session like this

  • @discoverlance

    @discoverlance

    2 ай бұрын

    I suppose when a new request comes in, the cookie store will be recreated since it's more of sharing data during the request. And it will always get the cookies from the client or browser request header as seen in parseCookies function so during any request, it will be fresh data from the request.

  • @AurelioPita
    @AurelioPita2 ай бұрын

    More under the hood videos please

  • @muhamedmouzoun
    @muhamedmouzoun2 ай бұрын

    Let's eat that cookie 😂!

  • @kkh0101
    @kkh01012 ай бұрын

    please remove nextjs repo. what a terrible framework but i have to learn it to eat bread.

  • @twitchizle

    @twitchizle

    2 ай бұрын

    Nextjs died with 13

Келесі