Show HN: React Routing in 120 lines (including comments)

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • react-snippets

    A sample of useful snippets in React

  • I updated the repo for this (and credited you in the code). If you have time, please feel free to review & improve as looks like quite a few people are using the code now: https://github.com/ashok-khanna/react-snippets/blob/main/Rou...

  • wouter

    🥢 A minimalist-friendly ~2.1KB routing for React and Preact

  • I'm a big fan of Wouter[0]. Most of my routing needs are taken care of by it.

    0: https://github.com/molefrog/wouter

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • crossroad

    🛣 A React library to handle navigation in your WebApp. Built with simple components and React Hooks so your code is cleaner. (by franciscop)

  • 1kb is likely a lot more than what is shown here; I made a "tiny" but very complete React Router package which is very complete and minified+gzip it's just 1.8kb https://crossroad.page/

  • universal-router

    Discontinued Universal routing both for backend and frontend (by fatih-erikli)

  • I use it like that and I am pretty happy with it.

    There's one thing, you should redirect all the pages to one single endpoint in server side order to use "pushState". Otherwise it will return 404 when you hit the refresh button. If you don't own a server, you can support routing with hashtag "#" and listen to "onhashchange" event instead of "popstate".

    Also, if you would like to support nested and dynamic routes (it's not possible with that code snippet in the github repository since it just checks like `path===currentPath`), you might look at the following solution:

    https://github.com/fatih-erikli/universal-router/blob/main/u...

    I use that solution in server-side and client-side so it works like Nextjs.

  • todomvc

    Helping you select an MV* framework - Todo apps for React.js, Ember.js, Angular, and many more

  • Yeah huh? It's like 'I'm selling the cheapest bag of chips ever' and it's just cuz you're putting less chips inside lol

    These short libs are apples to oranges unless we have a test suite or set of acceptance criteria. Something like https://todomvc.com/ and https://eugenkiss.github.io/7guis/tasks helps keep reqs constant.

  • react-simplest-router

    simplest router for React

  • making React small libraries like these is fun.

    I made one myself that was absolutely the simplest I could go for[0]

    0: https://github.com/ldd/react-simplest-router

  • awesome-go-orms

    ORMs for Go, most starred on GitHub.

  • > we'd see the same problem everywhere at the same scale

    we do. Every C app implements its own linked list or hash table library. The entire Scheme community is nothing but toy interpreters of various stages of completeness (you can tell a project is serious when they implement call/cc). How many game engines do you think exist? It's a meme that game devs like to spend more time on their pet game engine than actually making their game. How many ORMs do you think exist for ? At least half a dozen. At least. For any given language. Python, Ruby, Go[1]. ORMs, in particular, seem to get created over and over again. Probably because they are trivial to implement and allows one to voice their opinions on SQL abstraction (bike shedding).

    [1] https://github.com/d-tsuji/awesome-go-orms

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • page.js

    Micro client-side router inspired by the Express router

  • I've used a lot of routers and my favorite is still page.js[1]. It hasn't been updated in years. But it's small, is Express-compatible (i.e. server/client routes can use the same code), and, more importantly, is hackable. I'll never use a router tied to a certain framework again (react, nextjs, etc.) because you trade flexibility for perceived convenience (e.g. using folder structure as route structure, or React component tree as route structure). But it's a terrible trade-off that paints you into a corner later, IMO. Routing can get really niche and site-dependent, so having it fully under your control is worth it.

    [1] https://github.com/visionmedia/page.js

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts