Add Polar checkout to my Next.js space facts app with @polar-sh/nextjs: a Checkout route using POLAR_ACCESS_TOKEN in sandbox mode, absolute success and return URLs, and a Buy button that passes my product ID from an environment variable.
Write a Polar webhook route for my space facts app with the Webhooks adapter and POLAR_WEBHOOK_SECRET: on order paid give the customer access, on subscription active and revoked turn their plan on or off. Let errors throw so Polar retries.
Add a Polar customer portal link to the account page of my space facts app, matching customers by my own user id as the external customer ID, so users can manage subscriptions and download invoices.