Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Use url parameters in `@reach/router`

    Sara VieiraSara Vieira

    In this lesson, we will add url parameters to our application using the @reach/router library.

    We will use the example of getting the username prop from our location to greet a user.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    Instructor: Let me just add a user component. This is going to say "Hello," because I don't have the username yet. I'm going to say "Hello" and I'm going to close this H1 and then we're going to see how we can add this parameter.

    Let me do the same thing I have in here. I want to say "user." The path of this is going to be users/username. Let me add a link that is going to go to users/sarah, and this is Sarah. If I do this now, this one's going to say "Hello." To get the props here, I can say props and then I can say props.username.

    If I do this it now says "Hello Sarah." This is how you can add URL parameters using Reach Router.