npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

flare-router

v1.0.0

Published

Blazingly fast SPA-like router for static sites - Pure vanilla JS

Readme


flare-router 🔥

A 3.4kB zero-config router and intelligent prefetcher that makes static sites feel like blazingly fast SPAs. Transform any multi-page website into a lightning-fast experience without framework overhead.

Features

  • Ultra-Lightweight - Only 3.4kB gzipped bundle size
  • Zero Configuration - Works out of the box with any static site
  • Intelligent Prefetching - Automatic link prefetching with IntersectionObserver
  • SPA-like Navigation - Instant page transitions without full reloads
  • State Preservation - Long-lived JavaScript behaviors between navigations
  • Framework Agnostic - Drop-in solution for any website architecture
  • Modern Browser APIs - Built with IntersectionObserver, Fetch API, and History API

Project Structure

├── lib/
│   ├── main.js                # Main router entry point
│   ├── router.js              # Core router logic and navigation
│   ├── handlers.js            # Click and popstate event handlers
│   └── dom.js                 # DOM manipulation and head merging
├── example/                   # Example implementation
├── dist/                      # Built bundles
└── package.json               # Package configuration

Quick Start

Prerequisites: Modern browser with ES modules support

Get Running in 3 Steps

# 1. Install flare-router
npm install flare-router

# 2. Import and initialize
import flare from 'flare-router';
const router = flare();

# 3. That's it! Your site now feels blazingly fast

Example Implementation:

<!DOCTYPE html>
<html>
  <head>
    <title>My Fast Site</title>
  </head>
  <body>
    <nav>
      <a href="/">Home</a>
      <a href="/about">About</a>
      <a href="/contact">Contact</a>
    </nav>

    <main>
      <!-- Your content -->
    </main>

    <script type="module">
      import flare from 'flare-router';
      const router = flare({ prefetch: 'visible', log: true });
    </script>
  </body>
</html>

Tech Stack

Core: Vanilla JavaScript ES Modules, IntersectionObserver API, Fetch API, History API Build: esbuild for bundling Deployment: npm package with CDN support

Architecture

How flare-router Works:

  1. Intelligent Prefetching - Uses IntersectionObserver to detect visible links and prefetches them
  2. Event Interception - Captures click and popstate events for seamless navigation
  3. Smart DOM Updates - Fetches new pages, swaps <body> content, and merges <head> elements
  4. State Preservation - Maintains JavaScript state and long-lived behaviors between navigations

Development Scripts

# Build production bundles
npm run build

Advanced Usage

Router Configuration:

const router = flare({
  prefetch: 'visible', // 'visible', 'hover', or false
  log: true, // Enable debug logging
  pageTransitions: false, // Enable native browser transitions (experimental)
});

Programmatic Navigation:

// Navigate to specific routes
router.go('/dashboard');
router.back();
router.forward();

// Disable/enable router
router.enabled = false;

Event Handling:

// Listen to router events
window.addEventListener('flare:router:fetch', () => {
  showLoadingSpinner();
});

window.addEventListener('flare:router:fetch-progress', ({ detail }) => {
  updateProgressBar(detail.progress);
});

window.addEventListener('flare:router:end', () => {
  hideLoadingSpinner();
});

Link Control:

<!-- Opt-out specific links for full page reload -->
<a href="/external-site" data-cold>External Link</a>

<!-- Force head scripts to reload -->
<script src="/analytics.js" data-reload></script>

Code Examples

Basic Setup:

import flare from 'flare-router';

// Initialize with default settings
const router = flare();

Advanced Configuration:

import flare from 'flare-router';

// Full configuration
const router = flare({
  prefetch: 'visible',
  log: true,
  pageTransitions: false,
});

// Manual navigation
router.go('/products');

// Event listeners
window.addEventListener('flare:router:fetch', showLoader);
window.addEventListener('flare:router:end', hideLoader);

Progress Tracking:

window.addEventListener('flare:router:fetch-progress', ({ detail }) => {
  const progressBar = document.getElementById('progress-bar');
  const { progress, received, length } = detail;

  progressBar.style.width = `${progress}%`;
  console.log(`Downloaded ${received} of ${length} bytes`);
});

Browser Support

Supported: All modern browsers with ES modules, IntersectionObserver, Fetch API, and History API support

Fallback: Gracefully degrades to standard navigation in unsupported browsers

Framework Compatibility:

  • ✅ Static sites (HTML, Jekyll, Hugo, etc.)
  • ✅ Server-rendered applications
  • ✅ Astro (with considerations for hydration)
  • ❌ Next.js/Nuxt.js (already have client-side routing)

Contributing

  1. Fork and create feature branch
  2. Make changes following existing patterns
  3. Run npm run build
  4. Submit pull request

Development Workflow:

  • Uses esbuild for fast development builds
  • ESLint and Prettier for code quality

License

This project is licensed under the MIT License - see the LICENSE file for details.