CSS and Next.js updates, web accessibility principles, dynamic font scaling and efficient typing for redux-thunk
15 minutes
Frontend
Jul 14, 2025
14 minutes
node node_modules/next-pwa-pack/scripts/copy-pwa-files.mjs
# or
npx next-pwa-pack/scripts/copy-pwa-files.mjs
{ "name": "My app", "short_name": "My app", "description": "My app’s description", "start_url": "/", "display": "standalone", "background_color": "#ffffff", "theme_color": "#000000", "icons": [ { "src": "/icons/icon-192x192.png", "sizes": "192x192", "type": "image/png" }, { "src": "/icons/icon-512x512.png", "sizes": "512x512", "type": "image/png" } ]
}
import { PWAProvider } from "next-pwa-pack";
export default function layout({ children }) { return <PWAProvider>{children}</PWAProvider>;
}
import { PWAProvider } from "next-pwa-pack";
export default function layout({ children }) { return <PWAProvider devMode>{children}</PWAProvider>;
}
import { updateSWCache } from "next-pwa-pack";
// After the post is successfully created
const handleCreatePost = async (data) => { await createPost(data); // Refresh the blog and dashboard cache updateSWCache(["/blog", "/dashboard"]);
};
import { clearAllCache } from "next-pwa-pack";
const handleLogout = async () => { await logout(); await clearAllCache(); // Clear all caches router.push("/login");
};
import { usePWAStatus } from "next-pwa-pack";
function UpdateNotification() { const { hasUpdate, update } = usePWAStatus(); if (hasUpdate) { return ( <div className="update-banner"> <p>New version of the application is available</p> <button onClick={update}>Update</button> </div> ); } return null;
}
import { clearAllCache, reloadServiceWorker, updatePageCache, unregisterServiceWorkerAndClearCache, updateSWCache, disablePWACache, enablePWACache, usePWAStatus
} from "next-pwa-pack";
// Clears all caches associated with the service worker.
await clearAllCache();
// Reloads the service worker and refreshes the page.
await reloadServiceWorker();
// Refreshes the cache for the specified page (or the current page if not specified).
await updatePageCache("/about");
// Disables the service worker and clears the cache.
await unregisterServiceWorkerAndClearCache();
// Starts the signal for all tabs and refreshes the cache in the current tab.
// Can be called after revalidateTag on the client.
updateSWCache(["/page1", "/page2"]);
// Globally disables the PWA cache (before rebooting or calling enablePWACache).
disablePWACache();
// Globally enables the PWA cache (after disablePWACache call).
enablePWACache();
const { online, hasUpdate, swInstalled, update } = usePWAStatus();
// - `online` — online/offline status
// - `hasUpdate` — whether update is available
// - `swInstalled` — whether service worker is installed
// - `update()` — activate new application version