# @cerbos/hub

[![npm](https://img.shields.io/npm/v/@cerbos/hub?style=flat-square)](https://www.npmjs.com/package/@cerbos/hub)

Client library for interacting with [Cerbos Hub](https://www.cerbos.dev/product-cerbos-hub) from server-side Node.js applications.

## Prerequisites

- Node.js 20+

## Installation

```console
$ npm install @cerbos/hub
```

## Example usage

### Interacting with policy stores

```typescript
import { readFile } from "node:fs/promises";

import { credentialsFromEnv, StoresClient } from "@cerbos/hub";

const stores = new StoresClient({ credentials: credentialsFromEnv() });

const { newStoreVersion } = await stores.modifyFiles({
  storeId: "MWPKEMFX3CK1",
  operations: [
    {
      addOrUpdate: {
        path: "policy.yaml",
        contents: await readFile("path/to/policy.yaml"),
      },
    },
  ],
});
```

For more details, [see the `StoresClient` class documentation](https://cerbos.github.io/cerbos-sdk-javascript/classes/_cerbos_hub.StoresClient.html).

## CommonJS support

This package is ESM-only, but may be `require`d from CommonJS modules in Node.js versions 20.19.5+, 22.15+, and 24+.

## Further reading

- [API reference](https://cerbos.github.io/cerbos-sdk-javascript/modules/_cerbos_hub.html)
- [Cerbos Hub documentation](https://docs.cerbos.dev/cerbos-hub/)

## Get help

- [Join the Cerbos community on Slack](https://go.cerbos.io/slack)
- [Email us at help@cerbos.dev](mailto:help@cerbos.dev)
