Skip to content
Skillv1.0.0

stackblitz-hello-world

Boot a WebContainer, mount files, install npm packages, and run a dev server in the browser. Use when learning WebContainers, building browser-based IDEs, or running Node.js without a backend server.

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (plugins/saas-packs/stackblitz-pack/skills/stackblitz-hello-world/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill stackblitz-hello-world. Copyright stays with the author (MIT).

StackBlitz Hello World

Overview

Boot a WebContainer, mount a file system tree, install dependencies with npm, and start a dev server -- all running inside the browser tab. No backend server needed.

Prerequisites

  • @webcontainer/api installed (see stackblitz-install-auth)
  • Cross-origin isolation headers configured
  • Modern browser (Chrome 90+, Firefox 90+, Safari 16.4+)

Instructions

Step 1: Define File System Tree

import { WebContainer, FileSystemTree } from '@webcontainer/api';

const files: FileSystemTree = {
  'package.json': {
    file: {
      contents: JSON.stringify({
        name: 'wc-hello',
        scripts: { start: 'node index.js', dev: 'nodemon index.js' },
        dependencies: { express: '^4.18.0' },
      }),
    },
  },
  'index.js': {
    file: {
      contents: `
const express = require('express');
const app = express();
app.get('/', (req, res) => res.send('Hello from WebContainer!'));
app.listen(3000, () => console.log('Server running on port 3000'));
      `.trim(),
    },
  },
  src: {
    directory: {
      'utils.js': { file: { contents: 'module.exports = { greet: (n) => "Hello " + n };' } },
    },
  },
};

Step 2: Boot and Mount

const wc = await WebContainer.boot();
await wc.mount(files);

console.log('Files mounted. Installing dependencies...');

Step 3: Install Dependencies

const installProcess = await wc.spawn('npm', ['install']);

// Stream install output
installProcess.output.pipeTo(new WritableStream({
  write(data) { console.log(data); },
}));

const installCode = await installProcess.exit;
if (installCode !== 0) throw new Error(`npm install failed: exit ${installCode}`);
console.log('Dependencies installed.');

Step 4: Start Dev Server

const serverProcess = await wc.spawn('npm', ['start']);

serverProcess.output.pipeTo(new WritableStream({
  write(data) { console.log(data); },
}));

// Listen for server-ready event
wc.on('server-ready', (port, url) => {
  console.log(`Server ready at ${url} (port ${port})`);
  // Display in iframe
  document.querySelector('iframe')!.src = url;
});

Output

added 57 packages in 3s
Dependencies installed.
Server running on port 3000
Server ready at https://xxx.webcontainer.io (port 3000)

Error Handling

Error Cause Solution
npm install hangs Large dependency tree Use --prefer-offline or fewer deps
server-ready never fires App not listening on a port Ensure app.listen() is called
Port conflict Another process on same port Use a different port
ENOENT for file File not in mount tree Verify FileSystemTree structure

Resources

Next Steps

Proceed to stackblitz-local-dev-loop for development workflow setup.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-stackblitz-he-69c07d/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-stackblitz-he-69c07d.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-stackblitz-he-69c07d",
  "kind": "skill",
  "name": "stackblitz-hello-world",
  "description": "Boot a WebContainer, mount files, install npm packages, and run a dev server in the browser. Use when learning WebContainers, building browser-based IDEs, or running Node.js without a backend server. Trigger: \"stackblitz hello world\", \"webcontainer example\", \"run node in browser\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general_chat"
    ],
    "tags": [
      "skill-md",
      "saas",
      "ide",
      "webcontainers",
      "stackblitz",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Boot a WebContainer, mount files, install npm packages, and run a dev server in the browser. Use when learning WebContainers, building browser-based IDEs, or running Node.js without a backend server. Trigger: \"stackblitz hello world\", \"webcontainer example\", \"run node in browser\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "plugins/saas-packs/stackblitz-pack/skills/stackblitz-hello-world/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/plugins/saas-packs/stackblitz-pack/skills/stackblitz-hello-world/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/plugins/saas-packs/stackblitz-pack/skills/stackblitz-hello-world/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit,",
      "Bash(npm:*),",
      "Bash(node:*)"
    ],
    "license": "MIT"
  },
  "instructions": "# StackBlitz Hello World\n\n## Overview\n\nBoot a WebContainer, mount a file system tree, install dependencies with npm, and start a dev server -- all running inside the browser tab. No backend server needed.\n\n## Prerequisites\n\n- `@webcontainer/api` installed (see `stackblitz-install-auth`)\n- Cross-origin isolation headers configured\n- Modern browser (Chrome 90+, Firefox 90+, Safari 16.4+)\n\n## Instructions\n\n### Step 1: Define File System Tree\n\n```typescript\nimport { WebContainer, FileSystemTree } from '@webcontainer/api';\n\nconst files: FileSystemTree = {\n  'package.json': {\n    file: {\n      conte",
  "cost": {
    "context_tokens": 764
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-stackblitz-he-69c07d/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.