Next.js Explained: How cookies() uses AsyncLocalStorage

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024

Комментарии • 24

  • @janglad9136
    @janglad9136 6 месяцев назад +18

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

  • @KevinNYank
    @KevinNYank 6 месяцев назад +7

    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
    @nicolasguillenc 6 месяцев назад +4

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

    • @leerob
      @leerob 6 месяцев назад

      Glad you found it helpful!

  • @alexedev
    @alexedev 5 месяцев назад

    nice, please create more in-depth videos like this

  • @goldydog1
    @goldydog1 6 месяцев назад

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

  • @fayrouzadham4808
    @fayrouzadham4808 6 месяцев назад

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

  • @EricSproles-yf4pc
    @EricSproles-yf4pc 6 месяцев назад

    Can AsyncLocalStorage be used across Middleware and Server Components?

  • @hazemabdennadher5379
    @hazemabdennadher5379 6 месяцев назад

    what vs code theme are you using

  • @kasper369
    @kasper369 6 месяцев назад

    pretty neat stuff

  • @AurelioPita
    @AurelioPita 5 месяцев назад

    More under the hood videos please

  • @muhamedmouzoun
    @muhamedmouzoun 6 месяцев назад

    Let's eat that cookie 😂!

  • @thisweekinreact
    @thisweekinreact 6 месяцев назад +7

    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.

  • @en_kratia
    @en_kratia 4 месяца назад +1

    Use cookies() === bye bye SSG?

  • @gumi-emma
    @gumi-emma 6 месяцев назад +1

    How do you properly handle localstorage in a next js app

  • @hongz1
    @hongz1 5 месяцев назад

    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?

  • @rijkvanwel
    @rijkvanwel 6 месяцев назад +4

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

    • @mzerone-g6m
      @mzerone-g6m 6 месяцев назад

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

    • @mzerone-g6m
      @mzerone-g6m 6 месяцев назад

      It is like built-in redis

  • @yassinesafraoui
    @yassinesafraoui 6 месяцев назад

    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 6 месяцев назад

      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.

  • @soulessshoe
    @soulessshoe 6 месяцев назад

    great series!

  • @kkh0101
    @kkh0101 6 месяцев назад +1

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

    • @twitchizle
      @twitchizle 6 месяцев назад +1

      Nextjs died with 13