ufbr

August 8, 2026 ยท View on GitHub

Netlify Status

Universal File-Based Router - A framework-agnostic file-based routing solution for modern web applications.

ufbr automatically generates routes from your file structure, eliminating the need for manual route configuration. Perfect for building single-page applications with intuitive file organization.

Features

  • ๐Ÿ“ File-Based Routing - Routes automatically generated from your file structure
  • โšก Sync & Async Components - Support for both synchronous and asynchronous component loading
  • ๐Ÿ”— Nested Routes - Build hierarchical route structures effortlessly
  • ๐ŸŽฏ Dynamic Routes - Create parameterized routes with [param] syntax
  • ๐ŸŽจ Framework Agnostic - Works with Preact, Solid, Ziko, Vue, and more

Installation

npm install ufbr

Quick Start

Basic Usage

import { createFileBasedRouter } from 'ufbr/[FRAMEWORK]'

createFileBasedRouter({
  pages: import.meta.glob('./pages/**/*.[jsx,js]'),
  target: document.body
})

Demos

TechStackblitz Link
VanOpen in StackBlitz
PreactOpen in StackBlitz
SolidOpen in StackBlitz
Vue
Svelte

API

createFileBasedRouter(options)

Options:

  • pages (object) - Result of import.meta.glob() pattern with all page components
  • target (Element) - DOM element where the router will render components

File Structure Example

pages/
โ”œโ”€โ”€ index.[extension]           โ†’ /
โ”œโ”€โ”€ about.[extension]           โ†’ /about
โ”œโ”€โ”€ blog/
โ”‚   โ”œโ”€โ”€ index.[extension]       โ†’ /blog
โ”‚   โ””โ”€โ”€ [id].[extension]        โ†’ /blog/:id
โ””โ”€โ”€ user/
    โ””โ”€โ”€ [name].[extension]      โ†’ /user/:name

License

MIT