Skip to main content

OPA SDKs

You can quickly connect an application to Enterprise OPA or Open Policy Agent (OPA) using the following SDKs.

These are developed and supported by Styra:

Language RepoDocsPackage
JavaStyraInc/opa-javastyrainc.github.io/opa-java/javadoc com.styra/opa
TypeScriptStyraInc/opa-typescriptstyrainc.github.io/opa-typescript @styra/opa
@styra/opa
C#StyraInc/opa-csharpstyrainc.github.io/opa-csharp Styra.Opa

Framework-specific integrations:

Framework RepoDocsPackage
ReactStyraInc/opa-typescriptstyrainc.github.io/opa-typescript @styra/opa-react

Getting Started

npm:

npm add @styra/opa

Yarn:

yarn add @styra/opa zod
note

Yarn does not install peer dependencies automatically. You will need to install zod as shown above.

Code Examples

import { OPAClient } from "@styra/opa";

const serverURL = "http://opa-host:8181";
const opa = new OPAClient(serverURL);

const path = "authz/allow";
const input = {
subject: "alice",
action: "read",
resource: "/finance/reports/fy2038_budget.csv"
};
const result = await opa.evaluate(path, input);
console.log(result ? "allowed" : "denied");

Support

Got suggestions or need help? We're here! Please reach out to us on the Styra Community Slack.

Further Reading