Skip to content

Upgrade docs Better Auth and Polar to API 2026-10 - #3149

Open
nperez0111 wants to merge 2 commits into
mainfrom
upgrade/better-auth-polar-versioning-api
Open

nperez0111 wants to merge 2 commits into
mainfrom
upgrade/better-auth-polar-versioning-api

Conversation

@nperez0111

@nperez0111 nperez0111 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Upgrade docs auth/billing to Better Auth 1.7.7, @polar-sh/better-auth 2.0.0, and Polar SDK 1.0.1; pin the matching auth migration CLI.
  • Adopt Polar's 2026-10 API, versioned SDK functions and snake_case payloads; update the client plugin and auth middleware imports.
  • Preserve logged-out pay-first provisioning, customer linking, sign-in links, and subscription plan updates. Supply the new user provisioning source required by Better Auth.

Related: #2749 (dependency upgrade), #2870 (pay-first checkout).

Validation

  • Targeted type-aware lint/type check passed for server auth, client auth, and the Next.js auth route (three files).
  • Formatting, git diff --check, mocked auth/billing smoke checks, and offline frozen-lockfile installation passed.
  • Docs workspace dependency builds and editor dependency builds passed; Next.js development server served pricing and auth routes successfully. A full production Next.js build was not run.
  • Live Polar sandbox: completed logged-out monthly Business checkout; actual webhooks provisioned and linked the account; magic-link login produced a verified paid session.
  • Repeated a reconstructed, signed subscription.active payload twice: both requests returned 200 with no duplicate user. This was not a dashboard replay of the original event.
  • Actual sandbox scheduled cancellation preserved paid access; immediate revocation delivered webhooks and returned the authenticated session to Free.
  • Isolated production-copy rehearsal: restored the public schema into private local Postgres. Better Auth generate and migrate reported no migrations needed. All six tables' row counts and data hashes remained unchanged; no duplicate provider account keys were present. This was a schema rehearsal, not a runtime login test against restored records.
  • The CLI warned that existing verification.createdAt / updatedAt columns are nullable; neither contained nulls. That drift was not silently altered.

Production was accessed read-only for the copy; no production migrations or webhook changes were performed. The copied database, local SQLite data, and temporary Postgres instance were removed. Credentials, database dumps, and local dev proxy settings are not included in this PR. Smoke checks were temporary tooling, not new committed regression tests.

Production rollout (required, not performed by this PR)

  • Confirm Node.js 22.12+ and production environment variables; rotate credentials exposed during troubleshooting before rollout.
  • Take a fresh database backup; check duplicate (providerId, accountId) keys and review CLI generation against the actual target POSTGRES_URL. From docs/, run pnpm exec auth generate --config ./lib/auth.ts --output ./auth-migration.sql, then apply reviewed changes with pnpm exec auth migrate --config ./lib/auth.ts (the tested copy required none). Without POSTGRES_URL, development targets local SQLite instead.
  • Drain old-version Polar webhook deliveries using the existing handler. Coordinate deployment with changing the production /api/auth/polar/webhooks endpoint to API 2026-10; queued/redelivered events retain their original contract.
  • Verify email/password, verification, existing GitHub/sponsor accounts, and magic-link behavior; unverified accounts may require a password reset under Better Auth 1.7.
  • Smoke-test new/existing and authenticated/pay-first purchases, customer portal access, plan updates, cancellation/revocation, and repeat delivery. Monitor auth and webhook failures.

Rollback must coordinate the application, database state, and Polar webhook contract; reverting dependencies alone is insufficient.

Summary by CodeRabbit

  • Improvements
    • Updated the documentation site’s authentication and payment integration to work with the latest Polar services.
    • Improved account linking and account creation for pay-first checkouts.

@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
blocknote Ready Ready Preview Oct 2, 2026 2:51pm UTC
blocknote-website Ready Ready Preview Oct 2, 2026 2:51pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 73e7905b-d11e-43b0-99b5-427ad8fb4986

📥 Commits

Reviewing files that changed from the base of the PR and between c6f14b0 and 8cd3e41.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • docs/lib/auth-client.ts
  • docs/lib/auth.ts
  • docs/package.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The docs app updates Better Auth and Polar SDK dependencies and initialization. It also changes webhook product and customer field access, user creation options, customer linking, and the database migration command.

Changes

Better Auth and Polar upgrade

Layer / File(s) Summary
SDK and auth setup
docs/package.json, docs/lib/auth.ts, docs/lib/auth-client.ts
Dependencies and the migration command are updated. Polar client initialization and imports use the newer SDK entry points.
Webhook and customer handling
docs/lib/auth.ts
Webhook handling reads product_id and external_id. New Polar users are created with the "polar" method, and customer linking uses updateCustomers.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Suggested reviewers: yousefed

Merge Risk: ⚪ Minimal · up to 8cd3e

The dependency and webhook upgrade has no identified merge-blocking defect. Complete the planned deployment checks during rollout.

Architecture Summary

Architecture risk: 🔵 Low · up to 8cd3e

The change affects 1 system.

Changed systems: docs

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — docs (service) was modified; 3 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in docs/lib/auth-client.ts: The polarClient import now uses the package’s /client entry point instead of its root entry point.
  • observed — Modified behavior in docs/lib/auth.ts: Polar client setup now uses createPolarCore from the 2026-10 SDK instead of the older Polar client, passes environment rather than server, and asserts that POLAR_ACCESS_TOKEN is non-null. The createAuthMiddleware import now comes from better-auth/api rather than better-auth/plugins.
  • observed — Modified behavior in docs/lib/auth.ts: The webhook comment now names Polar’s external_id field instead of externalId.
  • observed — Modified behavior in docs/lib/auth.ts: The active-subscription branch now reads the product identifier from payload.data.product_id instead of payload.data.product.id.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: upgrading the docs Better Auth and Polar integration to the 2026-10 API.
Description check ✅ Passed The description is detailed and relevant. It explains the upgrade, rationale, changes, validation, production rollout requirements, and rollback considerations. It does not reproduce every template he…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the auth-client door,
New Polar fields arrive in store.
A customer finds the right user,
A migration runs a little newer.
The bunny hops through updates bright.

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@3149

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@3149

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@3149

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@3149

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@3149

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@3149

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@3149

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@3149

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@3149

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@3149

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@3149

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@3149

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@3149

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@3149

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@3149

@blocknote/xl-typst-exporter

npm i https://pkg.pr.new/@blocknote/xl-typst-exporter@3149

commit: 8cd3e41

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://TypeCellOS.github.io/BlockNote/pr-preview/pr-3149/

Built to branch gh-pages at 2026-10-02 15:06 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — 8cd3e41b Deployed Oct 2, 2026 by vercel[bot]
Preview – blocknote — 8cd3e41b Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant