3.0.2 • Published 4 days ago

@shopify/mini-oxygen v3.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 days ago

Mini Oxygen

Getting Started

MiniOxygen is a local runtime that simulates Oxygen production. It is based on Cloudflare's workerd via Miniflare.

To use MiniOxygen within your app, follow these steps:

Add @shopify/mini-oxygen as a dev dependency of your app:

npm install --save-dev @shopify/mini-oxygen

Import it and create a new instance of Mini Oxygen:

import {createMiniOxygen} from '@shopify/mini-oxygen';

const miniOxygen = createMiniOxygen({
  workers: [
    {
      name: 'main',
      modules: true,
      script: `export default {
        async fetch() {
          const response = await fetch("https://hydrogen.shopify.dev");
          return response;
        }
      }`,
    },
  ],
});

Dispatch requests to MiniOxygen from the browser or any other environment:

const response = await miniOxygen.dispatchFetch('http://placeholder');
// Or with the following code via network request:
// const {workerUrl} = await miniOxygen.ready;
// const response = await fetch(workerUrl);

console.log(await response.text());

await miniOxygen.dispose();

Legacy Node.js Sandbox runtime

The previous Node.js sandbox runtime has been moved to the @shopify/mini-oxygen/node export. It is not recommended for new projects, but can be used as follows:

import {createMiniOxygen} from '@shopify/mini-oxygen/node';

const miniOxygen = createMiniOxygen({
  script: `export default {
  async fetch() {
     const response = await fetch("https://hydrogen.shopify.dev");
     return response;
  }
 }`,
});

const response = await miniOxygen.dispatchFetch('http://placeholder');

console.log(await response.text());

await miniOxygen.dispose();
3.0.2

4 days ago

3.0.1

19 days ago

3.0.0

1 month ago

2.2.5

4 months ago

2.2.4

5 months ago

2.2.1

8 months ago

2.2.0

8 months ago

2.0.2

9 months ago

2.2.3

7 months ago

2.2.2

8 months ago

2.0.1

10 months ago

2.0.0

10 months ago

2.1.2

9 months ago

2.1.1

9 months ago

2.1.3

9 months ago

2.1.0

9 months ago

1.7.0

11 months ago

1.6.0

12 months ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.0.5

2 years ago