[READ-ONLY] Mirror of https://github.com/danielroe/cross-origin-storage. Load shared dependencies from Cross-Origin Storage (COS).
cross-origin-storage experimental nuxt vite vite-plugin
0

Configure Feed

Select the types of activity you want to include in your feed.

1# nuxt-cos 2 3> [!WARNING] 4> Experimental. The [Cross-Origin Storage API](https://github.com/WICG/cross-origin-storage) is an early-stage proposal with no native browser support yet, and the underlying chunk format is not stable. Do not depend on it in production. 5 6A Nuxt module that loads shared dependencies (such as `vue`) from [Cross-Origin Storage (COS)](https://github.com/WICG/cross-origin-storage). It extracts those dependencies into content-addressed chunks so that a COS-capable browser can reuse the same chunk across different sites instead of downloading it once per origin. 7 8It is a thin Nuxt wrapper around [`vite-plugin-cross-origin-storage`](https://github.com/danielroe/nuxt-cos/tree/main/packages/vite-plugin-cross-origin-storage); see that package for how the content addressing and sharing work. 9 10## Setup 11 12```bash 13npx nuxt module add nuxt-cos 14``` 15 16Or add it manually: 17 18```ts 19// nuxt.config.ts 20export default defineNuxtConfig({ 21 modules: ['nuxt-cos'], 22}) 23``` 24 25By default it manages `vue` and `@vue/*`. The module only runs in production builds (it is a no-op in dev), and it injects the COS loader into the server-rendered HTML, replacing Nuxt's default entry script. 26 27## Configuration 28 29```ts 30export default defineNuxtConfig({ 31 modules: ['nuxt-cos'], 32 cos: { 33 // Packages to extract into COS chunks. Matched against the imported 34 // specifier; a plain string is an exact match. Transitive dependencies 35 // are collected automatically. 36 packages: [/^(?:vue$|@vue\/)/], 37 }, 38}) 39``` 40 41| Option | Type | Default | Description | 42| --- | --- | --- | --- | 43| `packages` | `Array<string \| RegExp>` | `[/^(?:vue$\|@vue\/)/]` | Packages to extract into COS chunks. | 44 45## Browser support 46 47The [Cross-Origin Storage API](https://github.com/WICG/cross-origin-storage) is not yet in any browser. You can try it with the [Cross-Origin Storage browser extension](https://github.com/web-ai-community/cross-origin-storage-extension). Without it, chunks load over the network as usual, so your site keeps working; it just doesn't share them. 48 49## License 50 51MIT