Many thanks to Daniel Buchner for his post on deep links in single-page applications (SPA) that are hosted on GitHub Pages.

I’ve been using Facebook’s React framework to build BeeBee.social, starting from a clean Create React App project. There were some bumps along the road, but in general it’s been a great experience. Everything just works. That is, until I created an optimized build and hosted it on GitHub Pages.

Only the generated index.html and scripts are deployed, so when you try to deep link into the application, you’re rewarded with the GitHub Pages 404 error page.

There’s really no server configuration on GitHub Pages, but the redirect to a custom 404 is a great hook to add some javascript that works the deep link magic.

I won’t got into the details here. Daniel’s post has all the info you need to recreate this clever hack.

— Joe