For developers

Integration quickstart

Install the packages, create your first revocable consent grant, and check a permission — copy-pastable, in a few minutes.

1Install the packages

@rsp-protocol/core holds the consent primitives; @rsp-protocol/react adds hooks and components for React apps.

npm install @rsp-protocol/core @rsp-protocol/react
2Your first API call

Create a consent grant and check it with the core API before touching any data.

import { createConsent, hasConsent } from '@rsp-protocol/core'

// 1. Create a revocable consent grant: who may do what, in which context.
const grant = createConsent({
  subject: 'user_123',        // the person the data is about
  audience: 'twinly',         // the product asking for access
  scope: 'profile.read',      // the permission being granted
  context: 'supporter',       // identity context this applies to
})

// 2. Check the grant before doing anything with the data.
if (hasConsent(grant, 'profile.read')) {
  // ...safe to read the profile field here
}
3Wire it into React (optional)

Wrap your app in RspProvider and read grants with useConsent — the UI reacts automatically when consent is revoked.

import { RspProvider, useConsent } from '@rsp-protocol/react'

function App() {
  return (
    <RspProvider subject="user_123">
      <ProfileCard />
    </RspProvider>
  )
}

function ProfileCard() {
  // Reactive: re-renders when the grant is revoked.
  const { allowed } = useConsent('profile.read', { audience: 'twinly' })
  if (!allowed) return <p>Profile hidden</p>
  return <p>Profile visible</p>
}