FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Creating a Custom Router with React and the History API
How-ToWeb Development

Creating a Custom Router with React and the History API

via Dev.to ReactKenta Takeuchi13h ago

This article was originally published on bmf-tech.com . Overview Preparation First, let's understand the History API. GO TO MDN. MDN - History MDN - Manipulating the Browser History For those in a hurry, just understanding pushState and window.popstate should suffice. Specifications This router will support the following URLs: /post /post/:id /post/:id/:title It does not support query parameters. Packages Used We will skip the React-related packages. There is only one package used besides React: pillarjs/path-to-regexp This package helps with regular expressions for the URL part. I would like to write my own regular expressions eventually, but for now, I will rely on this package. Implementation Create Components for Navigation and Pages Prepare components corresponding to navigation and the pages. src/ ├── App.js ├── Dashboard.js ├── Home.js ├── Post.js └── Profile.js Implement Routing Now, let's implement the routing. We will prepare two components: Router and Route . Router is the c

Continue reading on Dev.to React

Opens in a new tab

Read Full Article
3 views

Related Articles

The Inheritance Trap: How to Avoid Fragile Base Classes
How-To

The Inheritance Trap: How to Avoid Fragile Base Classes

Medium Programming • 13h ago

Eighty Years Later, the Chemex Still Makes Better Coffee
How-To

Eighty Years Later, the Chemex Still Makes Better Coffee

Wired • 14h ago

The Day I Realized Coding Is Less About Computers and More About Learning How Humans Think
How-To

The Day I Realized Coding Is Less About Computers and More About Learning How Humans Think

Medium Programming • 14h ago

The Strange Advice Engineers Eventually Hear
How-To

The Strange Advice Engineers Eventually Hear

Medium Programming • 19h ago

How-To

A Gentle Introduction to Mercury

Lobsters • 19h ago

Discover More Articles