mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-17 12:16:31 +08:00
* Fixing Internal Links Internal links, like those found on [Available Scripts](https://facebook.github.io/create-react-app/docs/available-scripts) use absolute urls and therefore link to https://facebook.github.io/docs/deployment instead of https://facebook.github.io/create-react-app/docs/deployment. * changing to markdown links and fixing various broken internal links
23 lines
728 B
Markdown
23 lines
728 B
Markdown
---
|
|
id: adding-a-router
|
|
title: Adding a Router
|
|
---
|
|
|
|
Create React App doesn't prescribe a specific routing solution, but [React Router](https://reacttraining.com/react-router/web/) is the most popular one.
|
|
|
|
To add it, run:
|
|
|
|
```sh
|
|
npm install --save react-router-dom
|
|
```
|
|
|
|
Alternatively you may use `yarn`:
|
|
|
|
```sh
|
|
yarn add react-router-dom
|
|
```
|
|
|
|
To try it, delete all the code in `src/App.js` and replace it with any of the examples on its website. The [Basic Example](https://reacttraining.com/react-router/web/example/basic) is a good place to get started.
|
|
|
|
Note that [you may need to configure your production server to support client-side routing](deployment.md#serving-apps-with-client-side-routing) before deploying your app.
|