Which Hono Router Should I Use in This Case?

Hono has five different routers: 1. PatternRouter 2. SmartRouter 3. LinearRouter 4. TrieRouter 5. RegExpRouter I need a router that matches the pathname exactly, regardless of the order in which routes are defined. Meaning if in my source code, however I order or define my API paths and endpoints.
5 Replies
Arjix
Arjix2w ago
trierouter will match the pathname exactly iirc
Puppeteer
PuppeteerOP2w ago
I asked Gemini, ChatGPT, Claude, and Grok. All of them chose different ones, only Grok answered by TrieRouter, which is most likely right. Though an official confirmation from Hono team would be much helpful.
Arjix
Arjix2w ago
I've implemented a trie-router myself in kotlin, that's why I said it would most likely be the one you want
ambergristle
ambergristle2w ago
did you try reading the source code? routing handling is also pretty easy to test locally
Arjix
Arjix2w ago
TrieRouter splits the url in segments, and makes a tree out of them so the order of the routes does not matter

Did you find this page helpful?