React Router - Complete Tutorial

Поділитися
Вставка
  • Опубліковано 27 тра 2024
  • Join The Discord! → discord.cosdensolutions.io
    Source Code → github.com/cosdensolutions/co...
    VSCode Theme | Font → Material Theme Darker | Menlo, Monaco "monospace"
    In this video we will learn about React Router. React Router is a very popular navigation library in React. It allows for a very powerful and robust navigation solution in your React applications. It handle all of the navigation client side, which means that you do not need to reload the browser on every page visit. Everything all happens on the client side. Get ready, because you are going to learn a lot in this video!

КОМЕНТАРІ • 203

  • @user-ob9qm4br2j
    @user-ob9qm4br2j 3 місяці тому +67

    My man just explained the whole react-router through a story-like continuous manner

  • @tdematos
    @tdematos Місяць тому +8

    This has to be one of the most high-quality easy-to-understand React Router tutorials on the internet. Good stuff man! 🔥

  • @avrakadavra1552
    @avrakadavra1552 3 місяці тому +26

    Petition to change the title of the video with React Router 6 in a nutshell. Anyway, thank you for this tutorial

  • @damiansimonak7955
    @damiansimonak7955 3 місяці тому +4

    I cant believe. A lot of teachers have 1 hour or almost 4h videos a lot of theory what I didn't understand but now I get that finally. Thank you

  • @Hasaralc
    @Hasaralc 3 місяці тому +12

    this is the most clear lesson about react routers. much love

  • @lifeofaimie
    @lifeofaimie 3 місяці тому +6

    This was SO helpful, clear and concise. The perfect intro to React Router!

  • @thecanadian6145
    @thecanadian6145 3 місяці тому +1

    Youre a great teacher. Showing why you do things instead of just telling is great

  • @alvinyanson
    @alvinyanson 3 місяці тому +3

    I'm glad I found this channel. I've been using Angular for a quite long time and decided to give React a try and this is definitely my go to channel when learning React. Thank you.

  • @dastaten
    @dastaten 4 дні тому

    Hands down, the best, most informative video on how to implement React Router 6 the proper way. Thanks, brother.

  • @user-og5rw1nk7d
    @user-og5rw1nk7d 2 місяці тому

    Whenever i want to understand any react topic i just want to watch your video bcs you explain in very simple manner🔥🔥

  • @julienheng3880
    @julienheng3880 3 місяці тому +4

    yes! this is what i have been waiting for! thank you so much! another excellent tutorial

  • @chamithperera475
    @chamithperera475 2 місяці тому

    Mate, you are gifted at this. Keep on doing what you are doing, you were spot on, on everything. It was well articulated!

  • @seagull2345
    @seagull2345 3 місяці тому +3

    Love your tutorials brother, very clear and concise.

  • @g.ryanpeterson9686
    @g.ryanpeterson9686 3 місяці тому +1

    You released this exactly when I needed it.

  • @homerdarang2832
    @homerdarang2832 2 дні тому

    Finally! I came across for an hour looking for some clear implementation with react router6 in a proper way! Thank man!

  • @ichiroutakashima4503
    @ichiroutakashima4503 2 місяці тому +1

    I'll be honest here, I haven't really touched React and React Router for quite a while because I was busy with WebGL and R3F and threeJS so I've become rusty, but thanks to your videos I honestly got speed up to date despite documentations existing. This is easier to digest and read compared to their docs imo. Definitely worth a subscribe!

    • @afokerealityigho9003
      @afokerealityigho9003 Місяць тому

      their doc is simply a no no no i was reading their doc but nahh it's was just confusing that's why i came here i actually prefer docs over videos. I only watch videos after finishing doc or when the doc is too confusing
      the tutorial is really nice God bless him

  • @naziruadam3950
    @naziruadam3950 3 місяці тому

    You are an excellent presenter and explainer. I had to watch this video a couple of times to pick up your styles.😁

  • @VaibhavPrasad
    @VaibhavPrasad 26 днів тому

    Simple, clear, concise and to the point. Brilliant tutorial on v6. 🔥

  • @brajagopal4725
    @brajagopal4725 3 місяці тому

    Direct on-point tutorial. Just love it❤

  • @vikashgupta3305
    @vikashgupta3305 3 місяці тому +1

    great Explanation in flow, each concept was connected to previous concept....We want one more video on React-Router 2

  • @rahulpatil3942
    @rahulpatil3942 2 місяці тому

    This is a great and easy to follow introduction to react-router

  •  3 місяці тому

    you re a shining diamond on React field. thank you for amazing contents.

  • @iranna9065
    @iranna9065 3 місяці тому

    It was much needed. The best video on React router 6

  • @ujjwal4441
    @ujjwal4441 Місяць тому

    amazing tutorial! explaned everything in almost 20mins.

  • @rivvychica
    @rivvychica 3 місяці тому

    THANK YOU for this video, and I love the way you teach. I sometimes struggle with React Router even though it seems so simple in theory. Finally it just really clicked with me, and I am now subscribed!

  • @shubhamtarade
    @shubhamtarade 3 місяці тому

    Much needed tutorial to learn react router v6, thanks!!!

  • @rjwhite4424
    @rjwhite4424 3 місяці тому

    wasn't a COMPLETE tutorial but definitely taught me some new stuff. Good video!

    • @devdeclan
      @devdeclan 3 місяці тому

      I might do a vid like this, thanks for the inspo

    • @rjwhite4424
      @rjwhite4424 3 місяці тому

      if you do include how loaders and defer works. I've been trying to figure that out for weeks. @@devdeclan

  • @checker4174
    @checker4174 26 днів тому

    Your explanations are fantastic! you make the concepts so accessible and easy to follow

  • @ajlebeau
    @ajlebeau 2 місяці тому

    Your explanations are incredible! Thank you!

  • @alanford9260
    @alanford9260 3 місяці тому

    What a great job you did, bro! Thanks a lot for such a great video!

  • @mercyiskey9009
    @mercyiskey9009 3 місяці тому

    I understood everything you explained. Thank you!

  • @becharaalhosri6471
    @becharaalhosri6471 3 місяці тому +3

    Awesome tutorial man, I hope if I keep learning and watching your videos I can get a job as a react developer.

    • @mDHARYL
      @mDHARYL 3 місяці тому

      Of course you will learn it by doing

  • @runelillevang1011
    @runelillevang1011 3 місяці тому

    Best explanation i have found, it really helps you explain every step in detail!

  • @jakobjaworski9526
    @jakobjaworski9526 Місяць тому

    This saved me hours of work, you know. Thank you Sir.

  • @manojpatra4458
    @manojpatra4458 Місяць тому

    Thanks. You explained it nicely.

  • @annyotamo
    @annyotamo 3 місяці тому

    Once I watch your tutorial I never have to worry about forgetting the topic. Your explanations are the best.
    Please could you bring a typescript with react tutorial please!

  • @ahmedfernandez4695
    @ahmedfernandez4695 23 дні тому

    Thanks for the cristal clear explanation. Literally save me hours 💪🏽🔥

  • @johnacsyen
    @johnacsyen 2 місяці тому

    Very concise tutorial. Thanks for your effort in making this.

  • @thomasimbriago8257
    @thomasimbriago8257 Місяць тому

    Extremly helpful video, thanks!

  • @richiezo
    @richiezo 29 днів тому +1

    I love the way you explained it. 🤗🤭

  • @angelogaspar364
    @angelogaspar364 3 місяці тому

    Great content ! Direct to the point. Thank you

  • @nikawuladze953
    @nikawuladze953 Місяць тому

    probably best channel I have ever watched

  • @nextleveltech267
    @nextleveltech267 2 місяці тому +1

    Sir.... It was really useful content... Literally.............
    Your explanation was good... Love you sooo much.............❤️❤️❤️❤️❤️❤️

  • @user-zt4cm5zx5k
    @user-zt4cm5zx5k 14 днів тому

    very useful and easy to perceive, ty

  • @alminyana0
    @alminyana0 2 місяці тому

    Hi Cosden, grate video as usual. many thanks, mate

  • @DominatesYT
    @DominatesYT 2 місяці тому

    Amazing amazing video and explanation!
    Thank you!

  • @nakulnshet4230
    @nakulnshet4230 3 дні тому

    Perfect react-router tutorial !

  • @ernestadonu9110
    @ernestadonu9110 Місяць тому

    This is awesome the one of the best I have seen so far

  • @tomas6909
    @tomas6909 2 місяці тому

    Great work with this tutorial!! Greetings from Argentina

  • @moschg78
    @moschg78 3 місяці тому

    Great tutorial, thank you man!

  • @Arun_kumar001
    @Arun_kumar001 7 днів тому

    No words to say....Just awesome🥰

  • @ChristopherNolanski
    @ChristopherNolanski 29 днів тому

    Sir, I forsee a magnificent future for this channel. Concise, to the point, very articulate, you remind me to another great teacher of initials 'TNN'. You are the kind of creator that makes most bootcamps look like rubish😎. May I dream with a future Angular course? Just let me dream . Keep it up! 🤠

  • @youcancallmejoker340
    @youcancallmejoker340 Місяць тому

    Cheers. Amazing video!

  • @artistnahiart3728
    @artistnahiart3728 2 місяці тому

    Just want to say thanks. exact exact exact which I wanted

  • @user-wr5bs5yg4i
    @user-wr5bs5yg4i 3 місяці тому

    Great and simple explanation!

  • @davidadedeji3018
    @davidadedeji3018 2 дні тому

    The perfect tutorial for for routing

  • @stroutco2070
    @stroutco2070 23 дні тому

    Solid video 👌🏻
    Will def recommend

  • @hitendrapatil9991
    @hitendrapatil9991 3 місяці тому +1

    Awesome bro. Your are vdo's are very knowledgeableand anyone can understand easily. 🙏

  • @suprabhatkumar5478
    @suprabhatkumar5478 Місяць тому

    Thanks for this great video. Please consider adding Forms, loaders, actions as well.

  • @RabeaerisFracto
    @RabeaerisFracto 2 місяці тому

    Thanks a lot, i really needed this. So helpful, i really needed this. Suscribed!

  • @chowiee5688
    @chowiee5688 Місяць тому

    Thanks Man, I learn a lot from you nice one😎😎

  • @uvins
    @uvins Місяць тому

    Very thank you, this is the only working way!!!

  • @okpechisblog2385
    @okpechisblog2385 Місяць тому

    This is a great way to get started with react router though with the constant update on react i feel youll need to do an update course soon.
    good job

  • @Nashoflow95
    @Nashoflow95 3 місяці тому

    Que buen video bro! te ganaste un suscriptor

  • @mohamedsalimbensalem6118
    @mohamedsalimbensalem6118 3 місяці тому

    Ive watched all your videos and i learned alot thanks to you
    I suggest if u make a video about virtualization using package and then doing it from scratch

  • @ayushyapatel8645
    @ayushyapatel8645 3 місяці тому

    Hey bro just to let you know your knowledge game me more understanding than other courses i took . just so grateful . Also wondering if you can make a video about api integration in nex
    tJs

  • @LGelashvili
    @LGelashvili 3 місяці тому

    Your videos are awesome, bro.

  • @republicoftutorials6068
    @republicoftutorials6068 2 місяці тому

    Great explanation thank you

  • @Sofien_Steve
    @Sofien_Steve 2 місяці тому

    maybe change the channel's name to React Made Simple, what a clear explanation 👏👏

  • @omidgreat
    @omidgreat 3 місяці тому

    Thank you so much brother ❤😊 please more videos like this 😅

  • @alem182
    @alem182 2 місяці тому

    Great video!! thanks!

  • @victorm3807
    @victorm3807 3 місяці тому

    I really like your videos I follow you from Rwanda 🇷🇼, you explain topics very professional. We would highly appreciate that you can make a full React course that covers all the topics you gave us in the React roadmap!! Thanks and keep it up we like you!!

    • @cosdensolutions
      @cosdensolutions  3 місяці тому +3

      the course is currently being worked on!

  • @cwnhaernjqw
    @cwnhaernjqw 3 місяці тому +35

    It looks like you're crying in ye thumbnail 😂😂

  • @lamarkkhalifa3970
    @lamarkkhalifa3970 2 місяці тому

    dude you are such a life saver !!!!!!!!

  • @USPSLaura
    @USPSLaura Місяць тому

    great teacher 🧑‍🏫

  • @zamanEhsani
    @zamanEhsani 3 місяці тому

    nice and easy explanation.

  • @Abken.
    @Abken. 3 місяці тому +1

    Great video! I'm glad that RRv6 finally started getting more coverage lately, especially with the addition of Data APIs (loader). I would be curious to hear your opinion on the loader Data API in general, so I'm looking forward to a potential future video :D
    What do you think about the Data APIs in RRv6 in projects where there's already state management (e.g. RTK)? Do you feel that it gets kind of "confused" in the paradigm (declarative TS with React vs declarative React only) in your opinion or you see it as a viable synergy between RTK Query (or tanstack react query) and RRv6 Data APIs for example?
    I definitely see a little paradigm confusion + not enough TS support in RRv6's Data APIs, but it can also be a cool synergy for sure with RTK's caching in a project that already uses Redux (or tanstack otherwise). Maybe it needs a little bit more time to fully settle down...
    A "quick" example of a working project with deferred loader (RRv6 Data API) using RTKQ and TypeScript:
    // loaders
    export const itemsLoader = (() => defer({ dataAsync: store.dispatch(api.endpoints.getItems.initiate()).unwrap() })) satisfies LoaderFunction; // using npm i react-router-typesafe for type inferrence for the useLoaderData, error hooks and RRv6 Await component in React 18 Suspense, etc.
    // router
    ;
    export const Items = () => {
    const { dataAsync: itemsLoaderAsync } = useLoaderData(); // Note: it will be strongly typed based on the loader automatically
    return (


    {/* Note: items will be strongly typed automatically to the type coming from the query in the loader, e.g. Array */}
    {(items) => items.map((item) => {item.description})}


    );
    };
    export const ItemsLoading = () => Loading items...;
    export const ItemsErrorBoundary = () => {
    const routeLoaderError = useRouteError() as FetchBaseQueryError;
    const isValidError = isRouteErrorResponse(routeLoaderError) || isFetchQueryError(routeLoaderError);
    return (

    {isValidError && routeLoaderError.status === 'FETCH_ERROR' && Error: Connection to API failed}
    {isValidError && routeLoaderError.status === 400 && Error: Bad Request}
    {isValidError && routeLoaderError.status === 404 && Error: 404 Not found}

    );
    };
    export const isFetchQueryError = (error: unknown): error is FetchBaseQueryError => isObject(error) && 'status' in error;
    // the end
    All of this could have been done with just the RTKQ's useQuery hook that already has {data, loading, error} and split into the 3 components directly inside without React Router at all, but then with this approach we can throw errors in the loader or in the component and they will bubble up eventually to the RRv6's route's errorElement which is much safer and can be used like old-school error boundaries from OOP React + the Await component also has an errorElement prop that can utilize the same but for example with an optional boolean `fromItemsComponent` prop and render even more personalized errors inside the error boundary vs the more generic fallback when bubbled up to the route's errorElement while using the same component which again reuses the idea of error boundary from OOP React but in a much more powerful way (also as a functional component), so I see a lot of benefit in RRv6 Data API vs simply RTKQ or tanstack react query.
    I think it's quite cool to be able to use the best out of both worlds - modern State Management hooks (e.g. rtk caching and ability to write automated queries or manual async thunks /e.g. for tokens/) and React Router 6 Data API hooks when state management is not needed in the respective component. Both state management like RTKQ and RRv6 Data Loaders already allow us to ditch useEffects for fetching which is a huge step forward to what we had years ago, but I'm curious to see where the whole RRv6 Data API combined with modern state management redux/rtk/saga/tanstack/zustand will go and if one or the other will become obsolete entirely or many projects will find the more verbose synergy between the two still useful going forward with React 19 and potentially after improving the TS support on RRv6 Data API (since even with custom typesafe enhanced hooks it's not fun, e.g. RRv6's class DeferredData in LoaderData is still not exported and unusable as a type). Great times to be a TS frontend dev for sure. Looking forward to React's ecosystem in 2025 for sure, haven't given up on it yet

  • @LieseLu
    @LieseLu 25 днів тому

    Thank you a million times! Your video is so clear that I could just use react-router-dom in my project too! But I have problem of setting default page "/city" rather than "/", I checked severl methods like add index: true, use Navigate to redirect, , and set the basename as the documention said, but none of them worked, I used Browser router at last...

  • @abhitrana3425
    @abhitrana3425 2 місяці тому

    Very good tutorial!!!

  • @INetreba
    @INetreba 2 місяці тому

    good clear lesson

  • @colorblack8305
    @colorblack8305 3 місяці тому

    keep making *more stuff* man, yeah docs have more in-depth explanations but it's simply not viable for one to go through every doc just to use/learn some features, there's just too many things to learn & cover. More content would be helpful as it's like outsourcing the learning. And thanks your contents have been very helpful.

  • @shwetamane8774
    @shwetamane8774 3 місяці тому

    Great tutorial 👏

  • @morpheusmatrix1073
    @morpheusmatrix1073 2 дні тому

    Hi, great video. One question, where to place header and footer to work with the new version of react router. Having NavLink inside the header and the header outside of my RouterProvider gives an error due to NavLink. Tkx

  • @lukalastname8199
    @lukalastname8199 Місяць тому

    im too lazy to understand from docs, it was helpful and fast haha

  • @muhmmadali189
    @muhmmadali189 3 місяці тому +2

    Really nice content. Kindly make a video on how to plan a react web app from scratch.

  • @Host-Tach
    @Host-Tach Місяць тому

    Hello! Thank you very much for the video! Please tell me what library you use to use css at 8:55. please share your library. Sorry for my possibly strange English. I translated from Russian using a translator.

  • @muhammadshefain6073
    @muhammadshefain6073 Місяць тому

    Awesome tutorials

  • @emmanuelareiza9699
    @emmanuelareiza9699 3 дні тому

    Muchas Gracias Broder

  • @proostdaantv
    @proostdaantv 29 днів тому

    Great tutorial! However, i'm running into an issue; I have a Navbar and Footer component that's outside of the createBrowserRouter array, which breaks the application. I can't imagine I need to add the navbar and footer with every page/component, so how do I go about it? Thank you!

  • @chrisowuor605
    @chrisowuor605 Місяць тому

    thanks well explained how you would do a navbar without specifying other components as children of nav component

  • @ivanmosful
    @ivanmosful 8 днів тому

    Hi, can you please tell us what is the best way to do the type for useRouteError since it returns an "unknown" type? Thanks

  • @youssefmagdy7150
    @youssefmagdy7150 Місяць тому

    excellent tutorial thanks a lot
    if you make a more advanced tutorial it would be very appreciated 🙏

  • @user-jz8wx9op8j
    @user-jz8wx9op8j 2 місяці тому

    I love this guy

  • @stevenwoolston8620
    @stevenwoolston8620 2 місяці тому

    Any chance we can see the package.json so we know the npm package versions you’re using?

  • @muhammadmursalin8915
    @muhammadmursalin8915 2 місяці тому

    Great work.🎂🎂😀

  • @endlessnameless3613
    @endlessnameless3613 2 місяці тому

    It will nice to watch how you make 404 page on dynamic route.
    Thanx for this vid

  • @sylvestercampbell7892
    @sylvestercampbell7892 3 місяці тому

    Great fan of you👍

  • @n241195r
    @n241195r Місяць тому

    Great vid!

  • @DeSZR
    @DeSZR 3 місяці тому

    Thank you very much, very useful! Good job. I have two questions: 1. Are you using Bootstrap for styling? 2. Why are you using Visual Studio Code instead of Webstorm? (I think Webstorm is much more convenient)

    • @cosdensolutions
      @cosdensolutions  3 місяці тому +2

      nope, I use tailwind for my styles and VSCode is just great for me

    • @DeSZR
      @DeSZR 3 місяці тому

      @@cosdensolutionstailwind - very interesting, I’ve never even heard of it. I only see one minute lesson about tailwinds on your wonderful channel (really true). Would you like to make a video about this? Tell us about Your experience and the differences between mui, bootstrap and tailwind, and which You prefer.

    • @DeSZR
      @DeSZR 3 місяці тому

      @@cosdensolutions And thank you very much for your feedback!

  • @morningstar6877
    @morningstar6877 3 місяці тому +4

    i really love this channel but i work with js not typescript. Should i learn typescript and working tsx??

    • @mikokz2329
      @mikokz2329 3 місяці тому

      Sure. With typescript debugging is much easier.