Customer Portal

Where your customers can view & manage orders and subscriptions

The Customer Portal is a destination where your customers can see their orders and ongoing subscriptions. It’s also where they’re able to get hands on receipts, benefits, and more.

You can programmatically create the Customer Portal link for a given customer ID. Using the Polar API, all you need is to call the customerPortal endpoint. Here’s an example using our TypeScript SDK.

import { Polar } from "@polar-sh/sdk";

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

async function run() {
  const result = await polar.customerSessions.create({
    customerId: "<value>",
  });

  redirect(result.customerPortalUrl)
}

run();

Or, if you use NextJS as your framework, we have a handy utility which shortens down your code significantly.

// app/portal/route.ts
import { CustomerPortal } from "@polar-sh/nextjs";

export const GET = CustomerPortal({
  accessToken: process.env.POLAR_ACCESS_TOKEN,
  getCustomerId: async (req) => '<value>'
});