2021-06-14 12:31:30 +00:00
# Service worker
2021-10-11 17:18:38 +00:00
Explore the Service worker preset with Nitro to push the boundaries of Nuxt rendering to the edge.
2021-06-14 12:31:30 +00:00
2021-10-11 17:18:38 +00:00
::list
- Can be used for edge-side rendering
- No dependency on Node.js
- No Node.js environment and features
::
::alert{icon=IconPresets}
Back to [presets list ](/docs/deployment/presets ).
::
::alert{type=warning}
2021-06-14 12:31:30 +00:00
Deployment as service worker has some limitations since SSR code is not running in Node.js environment but pure JavaScript.
2021-10-11 17:18:38 +00:00
::
## Usage
You can use the [Nuxt config ](/docs/directory-structure/nuxt.config ) to explicity set the preset to use:
```ts [nuxt.config.js|ts]
export default {
nitro: {
preset: 'worker'
}
}
```
Or directly use the `NITRO_PRESET` environment variable when running `nuxt build` :
```bash
NITRO_PRESET=worker npx nuxt build
```
2021-06-14 12:31:30 +00:00
2021-10-11 17:18:38 +00:00
## Entrypoint
2021-06-14 12:31:30 +00:00
2021-10-11 17:18:38 +00:00
The worker preset produces a service worker that can provide full HTML rendering within a worker context (for example [Cloudflare Workers ](/docs/deployment/cloudflare )). It registers appropriate handlers for `fetch` , `install` and `activate` .
2021-06-14 12:31:30 +00:00
2021-10-11 17:18:38 +00:00
For more information you can see the [source code ](https://github.com/nuxt/framework/blob/main/packages/nitro/src/runtime/entries/service-worker.ts ).