Registry / web-framework / oc
library0.2.1jsnpmunverified

OpenComponents (OC) is an open-source JavaScript framework designed for developing and distributing server-side rendered HTML components, often described as 'serverless in the front-end world'. It abstracts infrastructure complexities, allowing development teams to build, publish, and consume front-end components seamlessly. Components can include Node.js logic for data fetching, along with HTML, CSS, and client-side JavaScript, supporting popular frameworks like React or Angular. The current stable version is 0.50.44. While continuously developed, the project notes that the API is still under heavy development and prone to change. Key differentiators include its focus on server-side rendering, transparent scaling, and a registry-based distribution model that allows components to be consumed via HTTP endpoints.

npm install oc
INSTALL
IMPORT
SIG · OC
O
oc
web-frameworkjavascriptv0.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Component
import { Component } from 'oc';
const Component = require('oc').Component;
Used for programmatically defining OpenComponents within a Node.js environment. Primarily for component authors or custom tooling.
Registry
import { Registry } from 'oc';
const Registry = require('oc').Registry;
The core class for creating and managing an OpenComponents registry, handling component storage and rendering. Essential for deploying components.
Client
import { Client } from 'oc';
const Client = require('oc').Client;
A programmatic client for interacting with an OpenComponents registry, allowing fetching and rendering components in a Node.js application.

Demonstrates how to start a minimal local OpenComponents registry using the `Registry` class, serving components from a specified directory.

import { Registry } from 'oc'; import path from 'path'; import fs from 'fs'; async function startLocalRegistry() { const componentsDir = path.join(process.cwd(), 'local-components'); // Create a dummy components directory if it doesn't exist if (!fs.existsSync(componentsDir)) { fs.mkdirSync(componentsDir); console.log(`Created directory: ${componentsDir}`); // Add a placeholder component if needed for testing, e.g., a simple 'hello-world' component // For a real component, you'd use 'oc-cli init' in this directory. console.log('Consider using `oc-cli init` inside local-components to create a component.'); } const registry = new Registry({ port: 3000, baseUrl: 'http://localhost:3000/', paths: [componentsDir], env: { name: 'development' } }); try { await registry.start(); console.log('OpenComponents Registry started successfully on port 3000.'); console.log(`Components will be loaded from: ${componentsDir}`); console.log('Access the registry at: http://localhost:3000/'); console.log('Press Ctrl+C to stop the server.'); } catch (err) { console.error('Failed to start OpenComponents Registry:', err); process.exit(1); } } startLocalRegistry();
oc --version
Debug
Known issues
breakingThe OpenComponents API is currently under heavy development. Breaking changes are frequent, and developers should expect to update their code when upgrading versions, especially between minor releases.
fix
Refer to the project's CHANGELOG.md and official documentation before upgrading. Pin exact versions or use a dependency management strategy that allows for manual review of updates.
affects: >=0.1.0
gotchaThis `oc` package is the core framework. For common component development and registry interaction, developers typically use `@opencomponents/oc-cli` for local development/publishing and `@opencomponents/oc-client` for consuming components in browser or Node.js.
fix
Ensure you are using the correct OpenComponents package for your specific task. `oc` is for building custom registries or advanced framework extensions.
affects: >=0.1.0
gotchaOpenComponents explicitly requires Node.js version 18 or higher. Using older Node.js versions will lead to runtime errors or unexpected behavior.
fix
Upgrade your Node.js environment to version 18 or newer using a version manager like nvm (Node Version Manager).
affects: <0.50.0
Errors
Common errors & fixes
TypeError: oc.Registry is not a constructor
Attempting to use `require('oc').Registry` with an older CommonJS syntax or when the package expects ESM, or an API change removed direct access to `Registry` via the top-level `oc` object.
fix
Ensure you are using `import { Registry } from 'oc';` in an ESM context. If using CommonJS, confirm the package structure still supports `require('oc').Registry` directly for your version, or check if it's a default export: `const Oc = require('oc'); const Registry = Oc.Registry;`
ERR_REQUIRE_ESM: Must use import to load ES Module
Attempting to use `require('oc')` in a CommonJS module when the `oc` package (or a part of it) has transitioned to being ESM-only.
fix
Convert your consuming module to ESM by adding `"type": "module"` to your `package.json` or changing your file extension to `.mjs`, then use `import { ... } from 'oc';`.
Error: EACCES: permission denied, mkdir '/local-components'
The Node.js process does not have write permissions to create the 'local-components' directory in the current working directory.
fix
Run the script with appropriate permissions, or change the `componentsDir` path to a location where the process has write access (e.g., `/tmp` or a user-specific directory).
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
oc — npm install oc · libregistry