frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

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

1•devfamdk•14h 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!

Theory of Everything: Solved

https://github.com/Cosmolalia/TOE
1•Cosmolalia•14m ago•0 comments

Betting against YouTube Financial Influencers beat the S&P 500 (risky though)?

https://papers.ssrn.com/sol3/papers.cfm?abstract_id=5315526
2•Corgipower12•31m ago•3 comments

Iris-WebP: Fast, efficient WebP encoder

https://halide.cx/iris/
1•Bogdanp•31m ago•0 comments

OpenAI to take cut of ChatGPT shopping sales in hunt for revenues

https://www.ft.com/content/449102a2-d270-4d68-8616-70bfbaf212de
3•mmarian•32m ago•2 comments

MacPlusDancer: Microsoft Plus! Dancers for macOS

https://github.com/samhenrigold/MacPlusDancer
2•archagon•35m ago•1 comments

Show HN: GST Calculator

https://gstcalculator.app
1•hapJam•55m ago•0 comments

1990 Networking: LAN Manager 2.0

https://www.os2museum.com/wp/1990-networking-lan-manager-2-0/
2•ingve•1h ago•0 comments

Original Xbox Hacks: The A20 CPU Gate

https://connortumbleson.com/2021/07/19/the-xbox-and-a20-line/
5•mattweinberg•1h ago•0 comments

Michael "The Grinder" Mizrachi Wins 2025 World Series of Poker Main Event

https://www.pokernews.com/news/2025/07/michael-mizrachi-wins-2025-wsop-main-event-49219.htm
2•indigodaddy•1h ago•0 comments

Watch videos in your preferred language

https://support.google.com/youtube/answer/13339776?hl=en
1•thunderbong•1h ago•1 comments

Show HN: ChainTok – Immortalize your love on Bitcoin's eternal ledger

https://app.chaintok.com
1•zzhan•1h ago•0 comments

Improving OSM lake polygons using Lidar data [video]

https://www.youtube.com/watch?v=4XxX8smv29M
2•marklit•1h ago•0 comments

Photos: The Scale of China's Solar-Power Projects

https://www.theatlantic.com/photography/archive/2025/07/photos-china-solar-power-energy/683488/
5•mhb•1h ago•0 comments

Dreamflow: create flutter apps with text prompts

https://dreamflow.app/
1•flwns•1h ago•0 comments

A Wide Reduction Trick

https://words.filippo.io/wide-reduction/
3•Bogdanp•1h ago•0 comments

International Math Olympiad 2025 Problems: How Well Will AI Do?

https://sugaku.net/content/imo-2025-problems/
4•mauriziocalo•1h ago•0 comments

I've been coding with AI for two years. Here is what I've learned

https://nathanpeck.com/ive-been-coding-with-ai-for-two-years-here-is-what-i-learned/
3•cebert•1h ago•0 comments

Links? Links – Infrequently Noted

https://infrequently.org/2025/07/links/
3•cratermoon•1h ago•0 comments

Cheating? Or the acumen of modern programming? FOSS, "AI", and human conscience

https://gist.github.com/guest271314/17c9daac37101538c9baa6df72aaaefb
2•thunderbong•2h ago•0 comments

LLM Benchmarking Shows Capabilities Doubling Every 7 Months

https://spectrum.ieee.org/llm-benchmarking-metr
3•mparramon•2h ago•0 comments

The Geological Sublime

https://harpers.org/archive/2025/07/the-geological-sublime-lewis-hyde-deep-time/
4•prismatic•2h ago•0 comments

Predicting Earthquakes

https://www.worksinprogress.news/p/a-50-million-foundation-model-to
1•sien•2h ago•0 comments

Garum Sardiniae in Tabula: Rediscovering the Ancient Taste of Roman Cuisine

https://exarc.net/issue-2023-3/at/garum-sardiniae-tabula-rediscovering-ancient-taste-roman-cuisine
1•airstrike•2h ago•0 comments

Mercedes-Benz adds support for Teams app, Intune integration, and Copilot

https://media.mercedes-benz.com/article/931e7af1-2d57-4e90-9e1e-252289e70648
1•throw0101d•2h ago•2 comments

Which Economic Tasks Are Performed with AI? Evidence from Claude Conversations

https://arxiv.org/abs/2503.04761
1•Bogdanp•2h ago•0 comments

The internet keeps getting worse. Let's talk about why [video]

https://www.youtube.com/watch?v=YcW9IB5e3_E
1•raythanwho•2h ago•0 comments

EurIPS: Present NeurIPS Papers in Europe

https://eurips.cc/
1•yza•2h ago•1 comments

NASA won't publish key climate change report online, citing no legal obligation

https://www.space.com/science/climate-change/nasa-wont-publish-key-climate-change-report-online-citing-no-legal-obligation-to-do-so
5•OutOfHere•2h ago•0 comments

Foreign YouTube stars secretly paid by UK Government for propaganda

https://www.thenational.scot/news/25318776.foreign-youtube-stars-secretly-paid-uk-government-propaganda/
6•duke_of_tharsis•2h ago•0 comments

Eight healthy babies born after IVF using DNA from three people

https://www.theguardian.com/science/2025/jul/16/eight-healthy-babies-born-after-ivf-using-dna-from-three-people
1•wicket•2h ago•1 comments