Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ git checkout -

You may copy and paste them, or put them into a custom shell script. You may also customize them for another hosting provider.

Note that if you add a router your app won't work with GitHub Pages becasue it doesn't natively support single page apps with frontend routing (unless it's the ugly hashtag kind). There is a simple workaround for this by adding a `404.html` file with a redirect script, see [Single Page Apps for GitHub Pages](https://github.com/rafrex/spa-github-pages).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s make it clear that it’s not an inherent problem with routers. It’s only relevant for the routers using HTML5 pushState history API under the hood. (I know you know it, but our readers probably won’t.)

Copy link
Contributor

@gaearon gaearon Jul 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s also avoid words like “simple” and “ugly”. They are very subjective. I would rather have a list of workarounds, like this:

  • You could switch from using HTML5 history API to routing with hashes. The URL will be longer and more verbose (for example, http://user.github.io/todomvc#todos/42). If you use React Router, you can switch to hashHistory for this effect. Read more about different history implementations in React Router.
  • Alternatively, you can use a trick to teach GitHub Pages to handle 404 by redirecting to your index.html page with a special parameter. You would need to add an 404.html file with the redirection code to the build folder before deploying your project, and you’ll need to add code handling that parameter to index.html. You can find a detailed explanation of this technique in this guide.

Copy link
Contributor Author

@rafgraph rafgraph Jul 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea that makes sense. I wasn't sure how much detail you wanted in the note since create-react-app doesn't include a router by default. I agree "simple" and "ugly" are more appropriate for a subjective comment than an objective doc.


### Something Missing?

If you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebookincubator/create-react-app/issues) or [contribute some!](https://github.com/facebookincubator/create-react-app/edit/master/template/README.md)