The `oc-client` package serves as a robust Node.js client for the OpenComponents micro-frontend framework, primarily facilitating server-side rendering of web components. It enables applications to consume, render, and manage distributed components from one or more registries. Key functionalities include instantiating a client with specific component versions and registry endpoints, warming up component caches, retrieving component metadata, and rendering components both individually and in batches. The current stable version is 4.0.2. The project is actively maintained and explicitly states it is under "heavy development," indicating a potentially rapid release cadence and a higher likelihood of API changes between minor versions. Its core differentiator lies in providing a streamlined way to integrate OpenComponents into Node.js applications, offering features like cache management, request header forwarding, and flexible component versioning to efficiently display dynamic content.
npm install oc-clientVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing the `oc-client` with registry and component configurations, warming up components, and rendering a single component.
Thoroughly review release notes and test suite updates with each new version. Pin dependencies to exact versions in your `package.json` to prevent unexpected breakage (`"oc-client": "4.0.2"`).
Ensure your Node.js environment is version 12 or newer to meet the package's declared engine requirements, overriding the outdated README advice.
Verify that `registries.serverRendering` is provided in the Client constructor options and points to a valid OpenComponents registry URL (e.g., `{ registries: { serverRendering: 'https://your-registry.com/' } }`).Use the ES Module `import` syntax: `import Client from 'oc-client';`.
Double-check that the `registries.serverRendering` URL provided to the `Client` constructor is correct and accessible from your Node.js application. Verify network connectivity and ensure the OpenComponents registry service is running and healthy. Inspect registry logs for specific error details.
Ensure the `registries` object is passed to the `Client` constructor and contains at least a `serverRendering` URL: `new Client({ registries: { serverRendering: 'https://your-registry.com/' }, ... });`.