Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
next-pwa is a plugin for Next.js that helps you turn your Next.js application into a Progressive Web App (PWA) with minimal configuration. It provides features like offline support, caching strategies, and service worker integration.
Offline Support
This configuration enables offline support by generating a service worker that caches your assets and pages, allowing your app to work offline.
const withPWA = require('next-pwa');
module.exports = withPWA({
pwa: {
dest: 'public'
}
});
Custom Caching Strategies
This configuration allows you to define custom caching strategies for different types of assets. In this example, images are cached using a 'CacheFirst' strategy.
const withPWA = require('next-pwa');
module.exports = withPWA({
pwa: {
dest: 'public',
runtimeCaching: [
{
urlPattern: /\.(?:png|jpg|jpeg|svg|gif)$/,
handler: 'CacheFirst',
options: {
cacheName: 'images',
expiration: {
maxEntries: 50,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
},
},
},
],
},
});
Service Worker Customization
This configuration allows you to customize the service worker behavior, such as enabling it only in production, skipping the waiting phase, and automatically registering it.
const withPWA = require('next-pwa');
module.exports = withPWA({
pwa: {
dest: 'public',
register: true,
skipWaiting: true,
disable: process.env.NODE_ENV === 'development',
},
});
workbox-webpack-plugin is a plugin for webpack that generates a service worker and precaches assets. It offers more granular control over caching strategies and service worker behavior compared to next-pwa, but requires more configuration.
next-offline is another Next.js plugin that helps you create a PWA. It provides similar functionalities to next-pwa, such as offline support and service worker integration, but it is less actively maintained.
sw-precache-webpack-plugin is a webpack plugin that generates a service worker using sw-precache. It is similar to workbox-webpack-plugin but is less feature-rich and is generally considered outdated in favor of Workbox.
FAQs
Next.js with PWA, powered by workbox.
The npm package next-pwa receives a total of 138,423 weekly downloads. As such, next-pwa popularity was classified as popular.
We found that next-pwa 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.