Dynamic routes
The homepage is ready with a full list of Pokémon. Good job!
Now, let's make the links point to an actual page by creating a new dynamic route.
Create the routes/pokemons
folder and add the following files inside it:
[pokemon].rs
[pokemon].tsx
The new route will handle any request that points to a path in the /pokemons/SOME_POKEMON
format.
Example URL: http://localhost:3000/pokemons/bulbasaur
.
Implementing a server-side route
Start with the server-side file by pasting the following content into [pokemon].rs
:
Implementing a client-side route
To set up the route client-side, simply paste the following code snippet into the [pokemon].tsx
file.
You should now get an error saying that the PokemonView
component does not exist. Let’s create it!
Finally, let's add a stylesheet to complete the look: