Quickstart

pnpm add @polar-sh/sdk
import { Polar } from '@polar-sh/sdk'

const polar = new Polar({
  accessToken: process.env['POLAR_ACCESS_TOKEN'] ?? '',
})

async function run() {
  const result = await polar.users.benefits.list({})

  for await (const page of result) {
    // Handle the page
    console.log(page)
  }
}

run()

Read more

Framework Adapters

Implement Checkout & Webhook handlers in 5 lines of code.

Sandbox Environment

You can configure the SDK so it hits the sandbox environment instead of the production one. You just need to add the server property to the configuration object:

const polar = new Polar({
  server: 'sandbox',
  accessToken: process.env['POLAR_ACCESS_TOKEN'] ?? '',
})