Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/mini-oxygen

Package Overview
Dependencies
Maintainers
24
Versions
282
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/mini-oxygen

Development assistant for custom Shopify Oxygen hosted storefronts

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-2.56%
Maintainers
24
Weekly downloads
 
Created
Source

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();

FAQs

Package last updated on 29 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc