A simple URL router for Preact applications that conditionally renders components based on the browser's address bar.
preact-router is a URL routing library for Preact applications that conditionally renders components based on the current browser URL. It solves the problem of managing navigation in single-page applications by providing a simple, declarative way to map URLs to components without the overhead of more complex routing solutions.
Developers building lightweight Preact applications who need basic routing functionality without the complexity of larger frameworks like React Router.
Developers choose preact-router for its simplicity, minimal API, and seamless integration with Preact's component model, offering essential routing features without unnecessary bloat.
:earth_americas: URL router for Preact.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows defining routes by passing `path` props directly to components within a `<Router>`, making it intuitive and aligned with Preact's component model, as shown in the usage example.
Automatically intercepts `<a>` element clicks for client-side navigation, with an optional `<Link>` component for active state styling, reducing manual event handling boilerplate.
Provides essential routing functionality without the bloat of larger solutions, keeping the bundle size small and integration straightforward, per its lightweight philosophy.
Supports alternative history bindings like hash history via the `history` prop, offering flexibility for different deployment scenarios, as demonstrated in the custom history example.
The README explicitly warns that preact-router is no longer actively developed and recommends preact-iso for new projects, posing a risk for long-term maintenance and feature updates.
Lacks built-in support for lazy loading, requiring external modules like preact-async-route, and does not handle complex nested routing or view composition natively.
Uses `path` and `default` props for routing, which can conflict with component props, forcing developers to avoid these names in their components, as noted in the caveats section.