{"id":16052173,"url":"https://github.com/ivandotv/nextjs-workbox-config","last_synced_at":"2025-03-17T16:31:50.584Z","repository":{"id":36990055,"uuid":"503506929","full_name":"ivandotv/nextjs-workbox-config","owner":"ivandotv","description":"Wrapper script around \"workbox-webpack-plugin\" that generates service worker for use with Next.js","archived":false,"fork":false,"pushed_at":"2024-12-16T01:55:37.000Z","size":142,"stargazers_count":1,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T00:51:14.327Z","etag":null,"topics":["nextjs","pwa","workbox","workbox-webpack-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivandotv.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-14T20:14:03.000Z","updated_at":"2022-07-13T20:55:15.000Z","dependencies_parsed_at":"2024-11-23T06:31:30.551Z","dependency_job_id":null,"html_url":"https://github.com/ivandotv/nextjs-workbox-config","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":"0.18181818181818177","last_synced_commit":"b24cd17e06af5b23c68a2e13e5d55b8a3abd30e8"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fnextjs-workbox-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fnextjs-workbox-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fnextjs-workbox-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fnextjs-workbox-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivandotv","download_url":"https://codeload.github.com/ivandotv/nextjs-workbox-config/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871860,"owners_count":20361378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nextjs","pwa","workbox","workbox-webpack-plugin"],"created_at":"2024-10-09T01:07:47.085Z","updated_at":"2025-03-17T16:31:50.270Z","avatar_url":"https://github.com/ivandotv.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Next.js Workbox Configuration\n\nWrapper script around [`workbox-webpack-plugin`](https://developer.chrome.com/docs/workbox/modules/workbox-webpack-plugin/) that generates service worker for use with Next.js. This is a modified script from the https://github.com/cansin/next-with-workbox.\n\n\n## Installation\n\n```sh\nnpm i -D nextjs-workbox-config\n```\n\n\n## Usage\n\nSetup [Next.js configuration](https://nextjs.org/docs/api-reference/next.config.js/introduction).\n\n```js\nimport withPlugins from 'next-compose-plugins'\nimport { withWorkbox } from 'nextjs-workbox-config'\n\n/**\n * @type {import('next').NextConfig}\n */\nconst nextConfig = {\n  workbox: {\n    //enable only in production\n    enable: process.env.NODE_ENV === 'production',\n    swSrc: 'src/sw.ts', // path to your service worker file\n    swDest: 'sw.js' // inside public dir path\n    dest:'public' // default destination for compiled service worker\n  }\n}\n\nexport default withPlugins([withWorkbox], nextConfig)\n```\n\nMinimal service worker setup:\n\n```ts\n/// \u003creference lib=\"es2017\" /\u003e\n/// \u003creference lib=\"WebWorker\" /\u003e\nimport { precacheAndRoute } from 'workbox-precaching'\nimport { registerRoute } from 'workbox-routing'\n\ndeclare const self: ServiceWorkerGlobalScope\n\nprecacheAndRoute(self.__WB_MANIFEST)\n\nexport {}\n\n```\n\nIf you want to to see a more complex service worker setup, take a look at [Next.js Material PWA Template repository](https://github.com/ivandotv/nextjs-material-pwa).\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivandotv%2Fnextjs-workbox-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivandotv%2Fnextjs-workbox-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivandotv%2Fnextjs-workbox-config/lists"}