![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
flamethrower-router
Advanced tools
Status: Meme
A 2kB zero-config router and prefetcher that makes a static site feel like a blazingly fast SPA.
Problem: Static sites feel slow and cannot easily share state between pages. This makes it difficult to create a pleasant user experience (UX) with JavaScript libraries because each new page needs to reboot your JS from scratch.
Rather than requiring a frontend framework to take control of the entire DOM, the goal is to make route changes on static sites feel faster, like a SPA.
IntersectionObserver
.fetch
to get the next page, swaps the <body>
out, merges the <head>
, but does not re-execute head scripts (unless asked to).This means you can have long-lived JavaScript behaviors between navigations. It works especially well with native web components.
npm i flamethrower-router
import flamethrower from 'flamethrower-router';
const router = flamethrower();
That's it. Your site now feels blazingly fast.
// with opts
const router = flamethrower({ prefetch: 'visible', log: false, pageTransitions: false });
// Navigate manually
router.go('/somewhere');
router.back();
router.forward();
// Listen to events
window.addEventListener('flamethrower:router:fetch', showLoader);
window.addEventListener('flamethrower:router:fetch-progress', updateProgressBar);
window.addEventListener('flamethrower:router:end', hideLoader);
// Disable it
router.enabled = false;
Opt-out of specific links for full page load.
<a href="/somewhere" data-cold></a>
Scripts in <body>
will run on every page change, but you can force scripts in the <head>
to run:
<script src="..." data-reload></script>
The fetch-progress event is a custom event, so usage will look something like this:
window.addEventListener('flamethrower:router:fetch-progress', ({ detail }) => {
const progressBar = document.getElementById('progress-bar');
// progress & length will be 0 if there is no Content-Length header
const bytesReceived = detail.received; // number
const length = detail.length; // number
progressBar.style.width = detail.progress + '%';
});
Prefecthing is disabled by default.
visible
: prefetch visible links on the page with IntersectionObserverhover
: prefetch links on hoverconst router = flamethrower({ prefetch: 'visible' });
Supported in all browsers? Yes. It will fallback to standard navigation if window.history
does not exist.
Does it work with Next.js? No, any framework that fully hydrates to an SPA does not need this - you already have a client-side router.
Does it work with Astro? I think so. It can share state between routes, but partially hydrated components may flash between routes.
Other things to know:
<head>
scripts run only on the first page load. <body>
scripts will still run on every page change (by design).Build it:
npm run dev
Serve the example:
npm run serve
Make sure all playwright tests pass before submitting new features.
npm run test
You can deploy Flamethrower to Vercel as follows:
npm run deploy
This uses the Build Output API and the Vercel CLI to deploy the /example
folder.
FAQs
Blazingly fast SPA-like router for static sites
We found that flamethrower-router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.