Last active
May 31, 2023 18:36
-
-
Save Akash52/dbc0f40b91fdbbf5a088014e7d4871c6 to your computer and use it in GitHub Desktop.
next.config.js for Next.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @type {import('next').NextConfig} */ | |
const withPWA = require("next-pwa")({ | |
dest: "public", // output directory | |
register: true, // register pwa | |
skipWaiting: true, // skip waiting for old service worker to be disabled | |
disable: process.env.NODE_ENV === "development", // disable in development | |
runtimeCaching: [ | |
//cache assets & data from external api | |
{ | |
urlPattern: /.*/i, | |
handler: "NetworkFirst", | |
options: { | |
cacheName: "others", // cache name | |
expiration: { | |
maxEntries: 32, // max cache entries | |
maxAgeSeconds: 24 * 60 * 60, // 24 hours | |
}, | |
networkTimeoutSeconds: 20, // fall back to cache if api does not response within 20 seconds | |
}, | |
}, | |
], | |
}); | |
const nextConfig = withPWA({ | |
reactStrictMode: false, | |
}); | |
module.exports = nextConfig; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment