Quickstart: Installation
Get started with SP8D, the fastest lock-free protocol for cross-thread communication in JavaScript and Node.js. This guide covers requirements, installation, and troubleshooting for high-performance messaging.
Install SP8D: Quickstart Guide for JavaScript & Node.js
Welcome to SP8D—the fastest, most reliable way to move data between threads and agents in your app. This guide will help you get SP8D running in your project quickly and correctly, with clear requirements and installation steps.
Requirements
Before installing, ensure your environment meets the following requirements. SP8D is designed for modern JavaScript runtimes and does not require any native or C++ dependencies.
- Node.js 18+ or any modern browser supporting SharedArrayBuffer and Atomics.
- Browser compatibility table →
In browsers, cross-origin headers may be required for SharedArrayBuffer.
Only modern browsers and Node.js 18+ are recommended for SP8D.
Diagram: Supported and unsupported environments for SP8D.
Quickstart: Install SP8D
SP8D can be installed using NPM for production use, or loaded via CDN for prototyping and browser demos. The diagram below shows how SP8D integrates into your application stack.
Diagram: SP8D installation and integration flow: NPM for production, CDN for prototyping.
SP8D installation and integration flow: install via NPM for production, or import from CDN for rapid prototyping.
NPM (Recommended)
To add SP8D to your project as a dependency, run:
npm install @sp8d/core
CDN/Unpkg (For Prototyping)
For quick browser demos or prototyping, you can import SP8D directly from a CDN:
<script type="module">
import {createChannel} from 'https://unpkg.com/@sp8d/core?module';
</script>
CommonJS
If you are using CommonJS modules (e.g., in older Node.js projects):
const { createChannel } = require("@sp8d/core");
Example package.json
{
"name": "my-sp8d-app",
"type": "module",
"dependencies": {
"@sp8d/core": "^x.y.z"
}
}
TypeScript Support
SP8D is written in TypeScript and ships with complete type definitions. No additional type packages are required. This ensures seamless integration and type safety in TypeScript projects.
For a minimal TypeScript example, see: Quickstart: Minimal Example →
Smoke Test: Verify Your Installation
After installation, run this code to verify SP8D is working in your project.
After installation, you can quickly verify that SP8D is working as expected by running the following code in your project:
import { createChannel } from "@sp8d/core";
const { channel } = createChannel({ slots: 4, slotSize: 64 });
console.log(channel.info()); // Prints protocol details
For a more detailed walkthrough, see the Quickstart: Minimal Example → or consult the API Reference →.
Troubleshooting
If you encounter issues during installation or usage, consider the following.
- “Cannot use SharedArrayBuffer”: Ensure you are in a secure context (https:// with COOP/COEP headers). See FAQ →
- Type errors? Make sure you are using Node.js 18+ or a supported bundler.
- Still stuck? Open an issue →