Ryan Toronto
Ryan Toronto
  • 25
  • 213 048
Handling RSC Errors in Next.js
In today's video we'll use an error boundary to refresh a React Server Component that threw an error. We'll also dive into transitions and see how they allow us to batch together state updates that finish at different times.
- 0:00 - Intro
- 1:06 - Error handling in Next.js
- 2:11 - Resetting without fixing the error
- 3:16 - Rerunning the server component
- 4:23 - Avoiding race conditions with transitions
- 6:47 - Why a transition is needed
For more videos on React Server Components check out Build UI: buildui.com/?
มุมมอง: 2 339

วีดีโอ

Where should this component run?
มุมมอง 1.7K5 หลายเดือนก่อน
I love how the RSC architecture approaches bundling and running React components. Non-interactive components run on the server, keeping the initial load fast and the bundle size small. Meanwhile, interactive components are run on the client, making the UI feel snappy and instantaneous. But what about components that need to run on both the server and client? How does the RSC architecture addres...
Asset loading in React
มุมมอง 1.9K6 หลายเดือนก่อน
In this video we’re going to take a look at the new Asset Loading feature coming to React 19. - 0:00 - Intro - 0:40 - Flash of unstyled content - 1:46 - Asset loading in React - 4:13 - Books app - 6:40 - The bookshelf component - 7:18 - How the transition works - 9:12 - Stylesheets do not unload Source code for books app: github.com/ryanto/asset-loading-suspense Check out my website: buildui.com
Out-of-order streaming in React
มุมมอง 6K7 หลายเดือนก่อน
Wish your users could see content instantly, even if data takes a second? In this video we're going to learn how out-of-order streaming allows React Server Components to render independently, showing your UI as soon as possible! - 0:00 - Intro - 0:15 - Introduction to streaming - 2:14 - Out-of-order streaming - 4:29 - Streaming and Suspense - 8:04 - Streaming multiple components - 9:41 - UI ide...
Preloading data (React's cache part 2)
มุมมอง 1.5K7 หลายเดือนก่อน
In this video we're going to continue where we left off in part 1 and use React's cache function to preload data. Watch part 1 here: th-cam.com/video/MxjCLqdk4G4/w-d-xo.html - 0:00 - Intro - 0:23 - Fetching data for the page - 4:15 - Why is the page slow? - 6:35 - Using cache to avoid waterfalls - 8:47 - Is preloading unused data okay? My website: buildui.com
React's new cache function
มุมมอง 10K7 หลายเดือนก่อน
In this video we're going to look at how React's cache function helps avoid unnecessary data requests. - 0:00 - Intro - 0:34 - Loading the current user - 2:31 - Using React’s cache function - 4:06 - Why not use props? - 7:51 - Good things to know about cache Preloading data with cache: th-cam.com/video/_gZ3ctkbGPo/w-d-xo.html Check out my course "Data fetching with React Server Components" here...
Why you can't set cookies in Server Components
มุมมอง 9K7 หลายเดือนก่อน
Today we're going look at why you can't set cookies when rendering server components in Next.js. - 0:00 - Intro - 1:22 - Setting cookies in RSC - 2:43 - Suspense - 5:13 - Streaming - 6:55 - Anatomy of an HTTP request - 9:22 - Setting cookies in Next.js For more videos on React check out buildui.com/
The useTransition hook
มุมมอง 1.6K11 หลายเดือนก่อน
Hi everyone! I wanted to share a free lesson on the useTransition hook from my course "Data fetching with React Server Components". - 0:00 - Intro - 0:23 - Start of lesson - 0:46 - useTransition hook - 2:22 - Styling the searching UI - 3:24 - Lesson outro - 3:56 - Outro Join Build UI: buildui.com/pricing Course: buildui.com/courses/react-server-components
Refresh React Server Components
มุมมอง 4.6Kปีที่แล้ว
In this video I'm going to show you how to automatically refresh a Next.js app whenever data in an external system changes. Code: buildui.com/recipes/refresh-app-router-cache-server-action - 0:00 - Intro - 1:23 - Server action - 4:18 - Refresh component - 6:49 - Interval with focus event - 9:47 - Outro Check out my latest course "Data fetching with React Server Components" exclusively on Build ...
Why I use Zod with Server Actions
มุมมอง 13Kปีที่แล้ว
In this video we're going to take a look at how Zod makes FormData easy to work with! Check out my Build UI course on React Server Components: buildui.com/courses/react-server-components - 0:00 - Intro - 0:23 - Introduction to Server Actions - 2:58 - Problems with FormData and TypeScript - 6:14 - Introduction to Zod - 10:17 - Dealing with Checkboxes - 12:35 - Code cleanup - 13:42 - Summary - 14...
Query params with TypeScript
มุมมอง 2.9Kปีที่แล้ว
In this video we're going to use TypeScript to recreate the type for query parameters.
Next.js Deploy Notifications
มุมมอง 7K2 ปีที่แล้ว
In this video we're going to build a simple version of the next-deploy-notifications library from scratch. Next deploy notifications: github.com/ryanto/next-deploy-notifications
Transitions that Suspend - React 18
มุมมอง 3K2 ปีที่แล้ว
Today we're going to take a look at the useTransition hook that's new in React 18. Source code: github.com/ryanto/suspense-transitions
Refactoring from useState to useReducer
มุมมอง 8812 ปีที่แล้ว
Today we're going to refactor a database app from useState to useReducer. Source: github.com/ryanto/use-state-vs-use-reducer
Testing images with Cypress
มุมมอง 11K2 ปีที่แล้ว
Today we'll write a test that asserts an image was correctly uploaded and displayed using Cypress. isFixtureImage command: gist.github.com/ryanto/76ed7013cc63565932ba3475403d6a73
Next.js Modal Routing
มุมมอง 33K2 ปีที่แล้ว
Next.js Modal Routing
Reacting to time - useClock hook
มุมมอง 6012 ปีที่แล้ว
Reacting to time - useClock hook
Synchronizing intervals in React
มุมมอง 4022 ปีที่แล้ว
Synchronizing intervals in React
Popup Menus in React with Popper.js
มุมมอง 21K3 ปีที่แล้ว
Popup Menus in React with Popper.js
Customizing Complex React Components
มุมมอง 3.1K4 ปีที่แล้ว
Customizing Complex React Components
Customizing Amplify's Login
มุมมอง 16K4 ปีที่แล้ว
Customizing Amplify's Login
Amplify login + React
มุมมอง 1.9K4 ปีที่แล้ว
Amplify login React
Debouncing with React Hooks
มุมมอง 9K4 ปีที่แล้ว
Debouncing with React Hooks
Why does React need keys - Part 1
มุมมอง 5634 ปีที่แล้ว
Why does React need keys - Part 1
Click Outside to Close - React Hook
มุมมอง 51K4 ปีที่แล้ว
Click Outside to Close - React Hook

ความคิดเห็น

  • @atharqadri3738
    @atharqadri3738 2 วันที่ผ่านมา

    But middleware is invoked for everyone request made from browser. Do we want to cookie-setting-logic to run on every request?

    • @RyanToronto
      @RyanToronto 11 ชั่วโมงที่ผ่านมา

      Check out the matching paths section of the Next.js docs to control which paths middleware should run on: nextjs.org/docs/app/building-your-application/routing/middleware#matching-paths

  • @AJPHIL-bt4me
    @AJPHIL-bt4me 3 วันที่ผ่านมา

    Gonna see if this can work for videos

  • @salos1982
    @salos1982 14 วันที่ผ่านมา

    That is such an awful reason why I cannot set cookies in the page server component. Why can I not set it before calling any Suspense? This solves the issue. And only if you using Suspense then I cannot set any cookies

    • @RyanToronto
      @RyanToronto 11 ชั่วโมงที่ผ่านมา

      I believe the reasoning is that if you ever refactor your page into one that uses suspense all the cookie code would then break. Middleware is a recommended way to do it from Next.js.

  • @ernestmalcolm7406
    @ernestmalcolm7406 17 วันที่ผ่านมา

    A very great video. One issue I have faced and wish to understand, what about setting the expiry time for that cookie, lets say a userToke, which is essential so when it expires it can be cleared. Hope the question makes sense. Hoping to hear from you soon

    • @RyanToronto
      @RyanToronto 10 ชั่วโมงที่ผ่านมา

      Great question! You can use the `maxAge` or `expires` option from Next's cookies().set function. See more details here: nextjs.org/docs/app/api-reference/functions/cookies#options

  • @manasranjansingh4374
    @manasranjansingh4374 27 วันที่ผ่านมา

    How to get cookies from browser in server component/server actions so we can send the cookies with request to backend API request. Please 🙏 reply I'm not able to find any solution

    • @RyanToronto
      @RyanToronto 10 ชั่วโมงที่ผ่านมา

      cookies().get('name') should allow your server component to get cookies from the incoming browser request.

  • @stevebendersky2056
    @stevebendersky2056 หลายเดือนก่อน

    Really nice, didn't know that and really useful.

    • @RyanToronto
      @RyanToronto 21 วันที่ผ่านมา

      Thanks you! Glad you enjoyed it

  • @codinginflow
    @codinginflow หลายเดือนก่อน

    This was very enlightening. Another place to set cookies is in route handlers!

  • @sahajranipa
    @sahajranipa หลายเดือนก่อน

    You can use my RSC philosophy whenever you have mutable data to handle you should have client components otherwise for immutable data you should use server components

    • @RyanToronto
      @RyanToronto หลายเดือนก่อน

      interesting way to summarize it! thanks!

  • @bojanraguz369
    @bojanraguz369 หลายเดือนก่อน

    What to do in a case when the user clicks on a route "/throws-sometimes" that's included in navbar? Can the error be reset via clicking on a link to the route within navbar? e.g. <Link href="/throws-sometimes">Throws sometimes</Link>

    • @RyanToronto
      @RyanToronto หลายเดือนก่อน

      I haven't tried it, but I wonder if it just works? If not, my first thought was you'd have to somehow get the reset into the nav bar so the error could be dismissed. Let me know what you come up with, I'd be very interested to know how you went about solving this type of problem.

    • @bojanraguz369
      @bojanraguz369 หลายเดือนก่อน

      @@RyanToronto Yeah, it's not working. I gonna try, if I'll make it I'll let you know :) Thanks

  • @emmanuelxs6143
    @emmanuelxs6143 หลายเดือนก่อน

    Can it work with aaync functions

    • @RyanToronto
      @RyanToronto หลายเดือนก่อน

      In the upcoming React 19 release there will be support for transitions to take an async function. Right now they are calling these "async transitions". Hope that answers your question!

    • @emmanuelxs6143
      @emmanuelxs6143 หลายเดือนก่อน

      @@RyanToronto I have been using them with server actions from next especially the isPending, I don't know if it is really a good idea since most server actions are asynchronous

    • @RyanToronto
      @RyanToronto หลายเดือนก่อน

      @@emmanuelxs6143 Oh yah with Next.js you can absolutely use async transitions

    • @emmanuelxs6143
      @emmanuelxs6143 หลายเดือนก่อน

      @@RyanToronto thanks for the update, I appreciate

  • @noabstruction
    @noabstruction 2 หลายเดือนก่อน

    You voice. Masallah ❤

  • @nrjdalal
    @nrjdalal 2 หลายเดือนก่อน

    bruh godly content

  • @lambmaster
    @lambmaster 2 หลายเดือนก่อน

    Awesome! But, why is this cache function in the React package, and not some Next package, especially if "vanilla" react doesn't even use it?

    • @RyanToronto
      @RyanToronto 2 หลายเดือนก่อน

      Great question! Cache is in the main react package because it's useful for any React Server Component to use.

  • @andrei-victor
    @andrei-victor 2 หลายเดือนก่อน

    Nice . Thank You! I'm using it in a list-feed and I wanted to maintain the scroll position, so I've added `scroll={false}` prop to the Link component and also`router.push("/", undefined, {scroll: false});` on modal close.

    • @RyanToronto
      @RyanToronto 2 หลายเดือนก่อน

      Oh awesome! That's great to know!

  • @fratelo9832
    @fratelo9832 2 หลายเดือนก่อน

    You forget to say that Middleware slow down app because it rerender every time when you change a route. I am trying to set cookie without midlware but can't find solution

    • @lukevinicius
      @lukevinicius 16 วันที่ผ่านมา

      Do you finded some solution?

  • @glenwinbernabe8937
    @glenwinbernabe8937 2 หลายเดือนก่อน

    hello Ryan, how can I use the cache function, I don't know how to get it from the React Canary. Great video by the way that's why I want to use it in my project.

    • @RyanToronto
      @RyanToronto 2 หลายเดือนก่อน

      The cache function is only available for React projects that use Server Components. If you're using RSC you can `import { cache } from "react";` and it will work. If you're not using RSC then cache is a no-op and doesn't do anything. Hopefully that helps!

    • @glenwinbernabe8937
      @glenwinbernabe8937 2 หลายเดือนก่อน

      @@RyanToronto hello Ryan, how do I know if I am using RSC? What is an example of a Server Components?

    • @glenwinbernabe8937
      @glenwinbernabe8937 2 หลายเดือนก่อน

      @@RyanToronto hello, it has something to do with the React Canary?

  • @akopaaa
    @akopaaa 2 หลายเดือนก่อน

    but then, how do i set a cookie from my api ? like i would like to update the session ID of the user of my website, and i can't seem to find how to save a cookie on their browser with the session id from the api request... because : cookies().set( bla bla bla ) will just set the cookie for the response but then it gets lost

    • @RyanToronto
      @RyanToronto 2 หลายเดือนก่อน

      cookies.set should do it! Take a look at the docs, you might need some options like how long until it expires: nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options

    • @akopaaa
      @akopaaa 2 หลายเดือนก่อน

      @@RyanToronto yes, already tried but the request comes from a server component so it only sets the cookie on the reply. Anyway i solved my problem so it doesnt really matter anymore, thanks for the help though :D

    • @pedromigacz
      @pedromigacz 25 วันที่ผ่านมา

      @@akopaaa How did you manage to solve it?

  • @luisllaboj
    @luisllaboj 2 หลายเดือนก่อน

    What would happen if wrap a transition in a transition? The outer transition holds a state for the inner transition or are they batched together or “unwrapped” like it was a promise passed to a promise constructor? lol idk if that makes sense

    • @RyanToronto
      @RyanToronto 2 หลายเดือนก่อน

      Great question! Transitions that wrap transitions are very common and I think saying they are "batched" is the right way of thinking about it. If a transition is inside another transition then neither state update will apply until they are both ready. In other words the state updates happen at the same time for all nested transitions.

    • @luisllaboj
      @luisllaboj 2 หลายเดือนก่อน

      @@RyanToronto cool, yea that makes sense, thanks!

  • @kanasva
    @kanasva 2 หลายเดือนก่อน

    Best explaination on earth. Thanks

    • @RyanToronto
      @RyanToronto 2 หลายเดือนก่อน

      Thank you!

  • @Aaronmoreno
    @Aaronmoreno 2 หลายเดือนก่อน

    Ryan, this is a game changer explination. So glad I found this channel. So well broken down

    • @RyanToronto
      @RyanToronto 2 หลายเดือนก่อน

      Thanks!!!

  • @arslanali774
    @arslanali774 3 หลายเดือนก่อน

    preloading restricted data in RSC makes sense as its not visible in any way to the end user. good video

    • @RyanToronto
      @RyanToronto 3 หลายเดือนก่อน

      Thanks!

  • @TaposhKumarBarmon
    @TaposhKumarBarmon 3 หลายเดือนก่อน

    Hi Ryan, it's a very instructive video. Cloud you please clarify how ISR feature will work for Modal?

    • @RyanToronto
      @RyanToronto 3 หลายเดือนก่อน

      Hey there! I think ISR should work with the modal. If the homepage or an image changes you'd need to ISR both pages.

  • @ElHawary
    @ElHawary 3 หลายเดือนก่อน

    Thank you, I was actually watching this in a private window "doing some testing", I had to login just to like and sub.

    • @RyanToronto
      @RyanToronto 3 หลายเดือนก่อน

      Wow thanks for the kind words! Really appreciate it!

  • @FarihaLiaqat
    @FarihaLiaqat 3 หลายเดือนก่อน

    Thank you for this video

  • @tauhid97k
    @tauhid97k 3 หลายเดือนก่อน

    Thanks. Can you make a video on setting cookies from a separate backend in the next.js server action? So, When I use server action and set credentials: "include" it doesn't work. This is because it's happening on the server. How can I forward the cookies in the browser to that separate API/backend server from server action?

    • @RyanToronto
      @RyanToronto 3 หลายเดือนก่อน

      Great question. You can use Next's built in cookies() function to read the cookies in your server action and then pass them into the fetch request your action is making to your backend.

    • @tauhid97k
      @tauhid97k 3 หลายเดือนก่อน

      @@RyanToronto I've tried this and several other methods but it's not consistent or maybe I don't quite understand the situation here. From the client side credentials: "include" works as expected. So I thought with your amazing explanation I could understand better. But Thanks. I'll keep trying.

  • @NetraPatwari
    @NetraPatwari 3 หลายเดือนก่อน

    Hey man ... I have a problem. i m using server actions to set cookies , with "use server" at top, i have created a actions directory in my-app , and have all my server side actions there. still i m facing this error. "" [Error]: Cookies can only be modified in a Server Action or Route Handler."". Actually my backend is in python (fastapi) and it worked fine last time , with same tech stack. this time i have made 2 routes also , for stripe webhook.., How can i solve this ...

    • @RyanToronto
      @RyanToronto 3 หลายเดือนก่อน

      Oh that's strange, setting cookies in server actions should absolutely work! I would try opening a bug report with a reproduction showing the error. Sorry I couldn't be of more help!

  • @JIPPOKIKKA
    @JIPPOKIKKA 4 หลายเดือนก่อน

    How about if you do Cookie Banner for asking permission for users to use cookies.

    • @RyanToronto
      @RyanToronto 3 หลายเดือนก่อน

      For a cookie banner use a server action to set the cookie when they click the accept button.

  • @cb73
    @cb73 4 หลายเดือนก่อน

    You should also be able to use the “Record” type instead: Record<string, string|undefined>

  • @cb73
    @cb73 4 หลายเดือนก่อน

    This is awesome thanks… I was literally just working on this. I ran into an issue trying to encrypt the cookies. The crypto library isn’t available in middleware because of the edge runtime. But… the web api for crypto is available which I’m working on now.

    • @RyanToronto
      @RyanToronto 4 หลายเดือนก่อน

      Nice! Did the web api end up working out for you?

    • @cb73
      @cb73 4 หลายเดือนก่อน

      @@RyanToronto no lol. Too hard. I’m already using a separate api written in golang that handles auth so I just wrote an endpoint that does the encryption (much easier in golang) - I call that in the middleware to give me the encrypted string I need to write a cookie. Works perfect for me.

  • @ColynBrown
    @ColynBrown 4 หลายเดือนก่อน

    I remember back in my PHP days we were constantly presented with "Headers already set" if we ever tried to set a cookie after the headers were set. Not sure why we can't be presented with the same error if we tried doing that

    • @RyanToronto
      @RyanToronto 4 หลายเดือนก่อน

      Oh that's a very neat idea

  • @raymondmichael4987
    @raymondmichael4987 4 หลายเดือนก่อน

    I keep smiling, thanks buddy😊

  • @zeynalabdinqdirov2386
    @zeynalabdinqdirov2386 4 หลายเดือนก่อน

    You can put a + in front of the value to convert the form.id to a string. Exp: +form.id. It will be shorter.🙂

  • @Dreamer4777
    @Dreamer4777 4 หลายเดือนก่อน

    THANK YOU, this video really helped me.

    • @RyanToronto
      @RyanToronto 4 หลายเดือนก่อน

      Glad it helped!

  • @garikmelqonyan6011
    @garikmelqonyan6011 4 หลายเดือนก่อน

    👍

  • @bideshbanerjee5506
    @bideshbanerjee5506 4 หลายเดือนก่อน

    Hello Ryan you are the only one who talks deep about RSC. I just want to know one thing that suppose for a particular page there are 4 - 5 components and an user changes or updates something in a component with server action then the whole json representation of every component of that page will get send by the server, is that how it works ?? and if it is, how optimal is that approach or it works differently ?? I know it's lot to ask...but will appreciate a video or response Thank you ❤

    • @RyanToronto
      @RyanToronto 4 หลายเดือนก่อน

      Thank you! To answer your question it really depends on the framework you are using and how your app and action is setup. If you're using Next.js with server actions you'll most likely want to call the built-in `revalidate()` function to update any components on the page.

  • @haydenpitout5151
    @haydenpitout5151 4 หลายเดือนก่อน

    Thanks Ryan ... great work as always 👍

    • @RyanToronto
      @RyanToronto 4 หลายเดือนก่อน

      Thanks!

  • @TfMukles
    @TfMukles 4 หลายเดือนก่อน

    make a video on refresh token in nextjs. I am facing the issues. In nextjs layout and page is stream simultaneously can you please make a video.

    • @RyanToronto
      @RyanToronto 4 หลายเดือนก่อน

      Hey there, would love to! Do you have an example app, mockups, or any code you can share so I can better understand the app and problem?

  • @silverlila
    @silverlila 5 หลายเดือนก่อน

    Great content, I really like the way you explain in such simple terms. Also noticed your @twofold/framework which seems great, have you thought on making a course on how something like that could be created?

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Thank you! Ya that's a great idea for a course. I think once React 19 is released there will be a great teaching story for RSC from scratch.

  • @erikplachta
    @erikplachta 5 หลายเดือนก่อน

    Appreciate the video. Nice to see startTransition solving some real world problems.

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Thanks Erik!

  • @mehrabmahmudpur6984
    @mehrabmahmudpur6984 5 หลายเดือนก่อน

    Great video. Thank's a lot.

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Glad you liked it!

  • @talhaibnemahmud
    @talhaibnemahmud 5 หลายเดือนก่อน

    Really good video

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Thanks!

  • @nick-ui
    @nick-ui 5 หลายเดือนก่อน

    Very unique solution with startTransition, how did you understand that it is necessary to use it

    • @erikplachta
      @erikplachta 5 หลายเดือนก่อน

      The refresh wasn’t happening because reset was executed before refresh had time to complete. - Router.Refresh is refreshing the connection to the server. - Reset restarts the component. No async option on refresh.

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Exactly what @erikplachta said! Since you want refresh and reset to happen at the same time they both need to be wrapped in a transition.

  • @vickonsscope6477
    @vickonsscope6477 5 หลายเดือนก่อน

    Best use case of the react transition mechanism... I really love this... Thank you a lot.🎉🎉

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Thank you! Glad you enjoyed it!

  • @luisllaboj
    @luisllaboj 5 หลายเดือนก่อน

    Is router.refresh() by default wrapped in a transition under the hood? Is that why reset() executes first? So, is Router.refresh() considered an asynchronous while reset() remains sync, unless we put both together in a transition and we force both to be completed before continuing?

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Yup, router.refresh uses a transition under the hood. We need to put both the reset and the router.refresh in the transition so React knows to not reset until the refresh is complete. We're telling React we'd like to transition to a state where the router is refreshed and the error boundary is reset. React won't apply the state update until those two things are ready. Another way of saying this: Putting them inside the transition tells React that they need to happen together.

  • @0xtz_
    @0xtz_ 5 หลายเดือนก่อน

    we have an issue in some pages we have a conditional display based on the url query and we need on each query change to reload to get the updated data 😢 any idea please hmmm even with parallel routes I need to noStore() to revalidate the data eeeeeh

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Sorry to hear about your issue. Do you have an example app or demo of your app anywhere?

    • @0xtz_
      @0xtz_ 5 หลายเดือนก่อน

      @@RyanToronto it's a private code that I can't share but it's a server component takes an id in the query and display the needed component I can provide a basic example of you have a discord or something hhh

  • @oscarljimenez5717
    @oscarljimenez5717 5 หลายเดือนก่อน

    Great video like always :) One question. What's the standard for showing clean errors on the console? Using a logger like "pino"? But then i can't throw an error that my error boundary can catch :/

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Thanks, glad you enjoyed it! Yah I think pino is great for logging. That said I'd still throw the error and have the error boundary catch it, but maybe also use pino right before you throw the error.

  • @raymondmichael4987
    @raymondmichael4987 5 หลายเดือนก่อน

    Just wow!! That's quite awesome man. Thanks, I'll definitely use it 😊

  • @manuellopezanido
    @manuellopezanido 5 หลายเดือนก่อน

    But is the home page a "use client" component?

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Heya! This video uses the pages router, which was before server/client components existed.

  • @Luisllaboj19
    @Luisllaboj19 5 หลายเดือนก่อน

    You're one of the few creators that show real life scenarios and real life solid solutions, not like most tutorials based on a script lol. I wanted to ask if you have a preferred way to handle errors, or the best practices, in javascript, especially when using the try catch syntax Should I be creating new custom Error classes and then handling them independently in the catch block with if(error instanceof CustomError) or is it better to always return an object followind a contract with either a data property for success >>> "{data: [....]}" or error property for error >>> "{error: ....}" Or maybe you know a better and more solid way, would be really helpful, thank you

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Great question! I don't think there's a one size fits all answer here. Both approaches (using the catch block and returning an object) can be useful at different times. I'd throw and error and use a catch block for the times when the error is an exception. Things where there's no obvious next step, like a database connection failing. Not much you can do in this situation, so throw an error and catch it somewhere else. And I'd return an error object for that times when there is a next step. If a login() function fails then I know what the next step is, it's to display an error message telling the user their credentials are wrong. That's not really an exceptional situation, so I'd return an error and let the code decide what to do next.

    • @Luisllaboj19
      @Luisllaboj19 5 หลายเดือนก่อน

      @@RyanToronto Thank you! That makes a lot of sense :D

  • @tejasyoutuber
    @tejasyoutuber 5 หลายเดือนก่อน

    Hi Ryan, Thanks for the detailed explanation on cookies. I am having one problem with cookies. I am setting cookies in middleware in response and setting of cookies will happen to particular route only. After setting the cookies, i am accessing the cookies in my navbar using next/headers. Every time i try to access the cookies i am getting old value and not the updated values that is being set in middle ware. Why is that? Can you please tell me what is the wrong here.

    • @RyanToronto
      @RyanToronto 5 หลายเดือนก่อน

      Hmm, sounds like there might be a bug somewhere! Have you tried making a minimal reproduction that highlights the issue?

    • @tejasyoutuber
      @tejasyoutuber 5 หลายเดือนก่อน

      @@RyanToronto No, I didn’t try in minimal app. May be i will check it out. I want to know is that possible to get updated value which is being set in the cookies through middleware. Example: i added the middleware and inside it i am setting the cookies which is next url path. I added the config which is /about (so this middleware is run only in about page). Now when i access the about page, cookies will set through middleware, now i want to access that cookie in about page. Every time i try to access that cookie i get old value not newly set cookie through middleware.