Skip to content

Instantly share code, notes, and snippets.

@tlack
tlack / custom-routes-with-react-page-example.md
Last active September 15, 2016 08:51
How to use custom routes with react-page and react-page-middleware

Note: This article was written December 24 2013, when react-page's version number is 0.2.0. This is all likely to change, so if the advice mentioned doesn't help, please reach out to the React community.

How to use custom URLs with the React-page router

Note: Technically, this functionality is provided by react-page-middleware. I'm going to refer to it generally as react-page, because I don't think they have enough of an independent identity (and usefulness outside of the whole react-page stack) to nitpick the naming.

react-page [https://github.com/facebook/react-page] is a cool new tool to link your ReactJS scripts in to your Node server config so that the entire site can be server rendered.

Unfortunately, it doesn't support custom routes - http://site.co/widget will always look for src/widget/index.js (or whatever your root elem is), even if you want http://site.co/widgets/new to go there instead.

Keybase proof

I hereby claim:

  • I am tlack on github.
  • I am tlack (https://keybase.io/tlack) on keybase.
  • I have a public key ASAfzQXduVcmaqcGmj495IpYs0u8ynUslUtUcEneasSOPQo

To claim this, I am signing this object: