Quick Start
A quick start guide to OpenPolicy
Installation
bun install -D @openpolicy/sdk @openpolicy/cli @openpolicy/coreUsage
You could also just ask Claude to do this for you.
// privacy.config.ts
import { definePrivacyPolicy } from "@openpolicy/sdk";
export default definePrivacyPolicy({
effectiveDate: "2026-01-01",
company: {
name: "Acme Inc.",
legalName: "Acme Corporation",
address: "123 Main St, Springfield, USA",
contact: "privacy@acme.com",
},
dataCollected: {
"Account Information": ["Name", "Email address"],
"Usage Data": ["Pages visited", "Browser type", "IP address"],
},
legalBasis: "Legitimate interests and consent",
retention: {
"Account data": "Until account deletion",
"Usage logs": "90 days",
},
cookies: {
essential: true,
analytics: false,
marketing: false,
},
thirdParties: [],
userRights: ["access", "erasure"],
jurisdictions: ["us", "eu"],
});# Generate the privacy policy in markdown and html format
openpolicy generate ./privacy.config.ts --format markdown,html --out ./src/policiesVite/React Usage
// src/privacy-policy.tsx
// Import the privacy policy as a raw string
import privacyPolicy from "./policies/privacy-policy.html?raw";
export default function PrivacyPolicyPage() {
return <div dangerouslySetInnerHTML={{ __html: privacyPolicy }} />;
}