frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: Drop-In PWA Support for Next.js with next-PWA-pack

1•devfamdk•6mo ago
Let’s be honest: building a real PWA in Next.js still sucks.

But when you actually need solid offline support, proper cache control, and version updates that don’t leave users stuck with stale data — suddenly you're deep in custom service worker hell, fighting App Router quirks and rewriting logic for the hundredth time.

So we open-sourced next-pwa-pack, a package that wraps all the annoying parts of adding PWA functionality to a Next.js project into something that's finally tolerable.

We do a lot of client work with Next.js, and “can you make it work offline?” comes up more often than you'd think. Every time, it was a mess — building service workers from scratch, wiring up caching strategies, dealing with versioning bugs across tabs, users getting stale content after deployments, etc.

Existing libraries either didn’t support the App Router well or came with so much config overhead that you might as well write your own service worker. So, we did — once — and turned it into a package. next-pwa-pack wires up a service worker with sane defaults: it caches HTML and static assets, supports offline fallback, and comes with a messaging system to control the cache from your app. No extra config required.

It also handles cache invalidation across browser tabs. That one was tricky — we ended up using localStorage + storage events to broadcast update signals, which has been working well for SPAs. To use it, you just wrap your app in the provided PWAProvider. It handles service worker registration, sets up messaging, and optionally gives you a dev panel during local development to observe or trigger cache behavior manually.

import { PWAProvider } from "next-pwa-pack";

export default function layout({ children }) { return <PWAProvider>{children}</PWAProvider>; }

And that’s pretty much it. The service worker kicks in, and you’re immediately getting basic offline support, background caching, and version-aware updates.

When the package is installed, it copies over a default sw.js, manifest.json, and offline.html into your public/ directory (if they don’t exist). These are all editable, of course — but they give you a working baseline.

The service worker handles two types of caching: HTML pages, with a default TTL of 10 minutes (configurable in sw.js).

There's a built-in messaging protocol using postMessage() so the client can ask the SW to update or clear specific caches. You can call things like updateSWCache(['/dashboard']) after a mutation or form submission, or use clearAllCache() after logout.

We also expose a hook (usePWAStatus) for checking things like whether a new version is available, if the service worker is installed, etc. Useful for adding those “update available” banners you see in real-world PWAs.

During dev, enabling devMode in the provider shows a small status widget in the corner that tells you whether the app is online, whether cache is being used, and gives you buttons to clear or disable it. It’s surprisingly helpful.

It only works over HTTPS (as required by the PWA spec), and it only caches GET requests — no API posts or sensitive data. TTLs and exclusions have to be edited in the service worker for now, though we plan to make that configurable via external JSON in the next version.

Also worth noting: if you’re using Incremental Static Regeneration (ISR), this doesn’t yet have direct support — though we’re exploring integration paths there too.

We built this to scratch our own itch, but it’s working well enough that we figured it might be useful to others. No weird magic. Just a working service worker with a nice DX.

Code: https://github.com/dev-family/next-pwa-pack Feedback welcome, and happy to answer questions or hear horror stories about your own PWA setup!

SectorC: A C Compiler in 512 bytes

https://xorvoid.com/sectorc.html
1•valyala•1m ago•0 comments

The API Is a Dead End; Machines Need a Labor Economy

1•bot_uid_life•2m ago•0 comments

Digital Iris [video]

https://www.youtube.com/watch?v=Kg_2MAgS_pE
1•Jyaif•3m ago•0 comments

New wave of GLP-1 drugs is coming–and they're stronger than Wegovy and Zepbound

https://www.scientificamerican.com/article/new-glp-1-weight-loss-drugs-are-coming-and-theyre-stro...
3•randycupertino•5m ago•0 comments

Convert tempo (BPM) to millisecond durations for musical note subdivisions

https://brylie.music/apps/bpm-calculator/
1•brylie•7m ago•0 comments

Show HN: Tasty A.F.

https://tastyaf.recipes/about
1•adammfrank•7m ago•0 comments

The Contagious Taste of Cancer

https://www.historytoday.com/archive/history-matters/contagious-taste-cancer
1•Thevet•9m ago•0 comments

U.S. Jobs Disappear at Fastest January Pace Since Great Recession

https://www.forbes.com/sites/mikestunson/2026/02/05/us-jobs-disappear-at-fastest-january-pace-sin...
1•alephnerd•9m ago•0 comments

Bithumb mistakenly hands out $195M in Bitcoin to users in 'Random Box' giveaway

https://koreajoongangdaily.joins.com/news/2026-02-07/business/finance/Crypto-exchange-Bithumb-mis...
1•giuliomagnifico•9m ago•0 comments

Beyond Agentic Coding

https://haskellforall.com/2026/02/beyond-agentic-coding
3•todsacerdoti•11m ago•0 comments

OpenClaw ClawHub Broken Windows Theory – If basic sorting isn't working what is?

https://www.loom.com/embed/e26a750c0c754312b032e2290630853d
1•kaicianflone•13m ago•0 comments

OpenBSD Copyright Policy

https://www.openbsd.org/policy.html
1•Panino•13m ago•0 comments

OpenClaw Creator: Why 80% of Apps Will Disappear

https://www.youtube.com/watch?v=4uzGDAoNOZc
2•schwentkerr•17m ago•0 comments

What Happens When Technical Debt Vanishes?

https://ieeexplore.ieee.org/document/11316905
2•blenderob•18m ago•0 comments

AI Is Finally Eating Software's Total Market: Here's What's Next

https://vinvashishta.substack.com/p/ai-is-finally-eating-softwares-total
3•gmays•19m ago•0 comments

Computer Science from the Bottom Up

https://www.bottomupcs.com/
2•gurjeet•19m ago•0 comments

Show HN: A toy compiler I built in high school (runs in browser)

https://vire-lang.web.app
1•xeouz•21m ago•1 comments

You don't need Mac mini to run OpenClaw

https://runclaw.sh
1•rutagandasalim•22m ago•0 comments

Learning to Reason in 13 Parameters

https://arxiv.org/abs/2602.04118
2•nicholascarolan•24m ago•0 comments

Convergent Discovery of Critical Phenomena Mathematics Across Disciplines

https://arxiv.org/abs/2601.22389
1•energyscholar•24m ago•1 comments

Ask HN: Will GPU and RAM prices ever go down?

1•alentred•24m ago•1 comments

From hunger to luxury: The story behind the most expensive rice (2025)

https://www.cnn.com/travel/japan-expensive-rice-kinmemai-premium-intl-hnk-dst
2•mooreds•25m ago•0 comments

Substack makes money from hosting Nazi newsletters

https://www.theguardian.com/media/2026/feb/07/revealed-how-substack-makes-money-from-hosting-nazi...
5•mindracer•26m ago•0 comments

A New Crypto Winter Is Here and Even the Biggest Bulls Aren't Certain Why

https://www.wsj.com/finance/currencies/a-new-crypto-winter-is-here-and-even-the-biggest-bulls-are...
1•thm•26m ago•0 comments

Moltbook was peak AI theater

https://www.technologyreview.com/2026/02/06/1132448/moltbook-was-peak-ai-theater/
2•Brajeshwar•27m ago•0 comments

Why Claude Cowork is a math problem Indian IT can't solve

https://restofworld.org/2026/indian-it-ai-stock-crash-claude-cowork/
3•Brajeshwar•27m ago•0 comments

Show HN: Built an space travel calculator with vanilla JavaScript v2

https://www.cosmicodometer.space/
2•captainnemo729•27m ago•0 comments

Why a 175-Year-Old Glassmaker Is Suddenly an AI Superstar

https://www.wsj.com/tech/corning-fiber-optics-ai-e045ba3b
1•Brajeshwar•27m ago•0 comments

Micro-Front Ends in 2026: Architecture Win or Enterprise Tax?

https://iocombats.com/blogs/micro-frontends-in-2026
2•ghazikhan205•30m ago•1 comments

These White-Collar Workers Actually Made the Switch to a Trade

https://www.wsj.com/lifestyle/careers/white-collar-mid-career-trades-caca4b5f
1•impish9208•30m ago•1 comments