Nuxt/docs/content/3.docs/8.deployment/99.presets/service-worker.md
Daniel Roe 1a39eff502
docs: update migration guide for nuxt 3 (#3819)
Co-authored-by: Dan Pastori <dan@521dimensions.com>
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
Co-authored-by: pooya parsa <pyapar@gmail.com>
2022-03-30 19:32:30 +02:00

1.2 KiB

Service worker

Explore the Service worker preset with Nitro to push the boundaries of Nuxt rendering to the edge.

::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. ::

::alert{type=warning} Deployment as service worker has some limitations since SSR code is not running in Node.js environment but pure JavaScript. ::

Usage

You can use the Nuxt config to explicitly set the preset to use:

export default {
  nitro: {
    preset: 'worker'
  }
}

Or directly use the NITRO_PRESET environment variable when running nuxt build:

NITRO_PRESET=worker npx nuxt build

Entry point

The worker preset produces a service worker that can provide full HTML rendering within a worker context (for example Cloudflare Workers). It registers appropriate handlers for fetch, install and activate.

For more information you can see the source code.