[PR #5533] feat(email-verification): with otp and link together #6068

Open
opened 2026-03-13 12:46:19 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5533
Author: @okisdev
Created: 10/24/2025
Status: 🔄 Open

Base: canaryHead: feat(email-verification)/with-otp


📝 Commits (10+)

  • 1545df8 feat(email-verification): with otp
  • 4334ecc feat(email-verification): with otp
  • ea9ac88 feat(email-verification): with otp
  • b461f79 feat(email-verification): with otp
  • 1ed9256 feat(email-verification): with otp
  • 7902408 feat(email-verification): with otp
  • 107484c feat(email-verification): with otp
  • 742627f Merge branch 'canary' into feat(email-verification)/with-otp
  • 5fcfcec feat(email-verification): with otp
  • 4242197 Merge branch 'canary' into feat(email-verification)/with-otp

📊 Changes

10 files changed (+623 additions, -12 deletions)

View changed files

📝 docs/content/docs/concepts/email.mdx (+129 -3)
📝 docs/content/docs/plugins/email-otp.mdx (+14 -0)
📝 docs/content/docs/reference/options.mdx (+25 -7)
📝 packages/better-auth/src/api/index.ts (+2 -0)
📝 packages/better-auth/src/api/routes/email-verification.test.ts (+199 -0)
📝 packages/better-auth/src/api/routes/email-verification.ts (+213 -1)
📝 packages/better-auth/src/api/routes/sign-up.ts (+20 -0)
📝 packages/better-auth/src/client/config.ts (+2 -1)
📝 packages/core/src/types/init-options.ts (+17 -0)
📝 packages/telemetry/src/detectors/detect-auth-config.ts (+2 -0)

📄 Description

This PR intros an new function to send email verification with OTP in order to let have otp and verification together. Suggested on #5475 during supabase auth migration.

This PR adds the following:

  • new /verify-email/otp to send email verification with otp together
  • add related test cases
  • update docs

close https://github.com/better-auth/better-auth/issues/5475


Summary by cubic

Add link + OTP email verification so users can verify via a link or a code in the same email. Introduces a new POST /verify-email/otp endpoint and the includeOTP option in emailVerification.

  • New Features

    • New endpoint: POST /verify-email/otp for code-based verification.
    • Optional OTP in sendVerificationEmail when includeOTP is true.
    • New config: emailVerification.includeOTP and emailVerification.otpLength.
    • OTP generation and storage with expiry (defaults to 1 hour).
    • Client SDK support: client.verifyEmail.otp(...).
    • Updated docs and comprehensive tests; telemetry now reports includeOTP/otpLength.
  • Migration

    • Enable emailVerification.includeOTP to send both link and OTP.
    • Update sendVerificationEmail to handle the optional otp field and include it in the email.
    • Optionally add a UI that calls client.verifyEmail.otp({ email, otp }) for code entry.

Written for commit bd9173ec11. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5533 **Author:** [@okisdev](https://github.com/okisdev) **Created:** 10/24/2025 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `feat(email-verification)/with-otp` --- ### 📝 Commits (10+) - [`1545df8`](https://github.com/better-auth/better-auth/commit/1545df831263072d279536bf890e416ce5debddc) feat(email-verification): with otp - [`4334ecc`](https://github.com/better-auth/better-auth/commit/4334ecc19bb85eeae0bb6e28edc5883ac3f04ce0) feat(email-verification): with otp - [`ea9ac88`](https://github.com/better-auth/better-auth/commit/ea9ac888372df204450b106ed329a9bbc4b24890) feat(email-verification): with otp - [`b461f79`](https://github.com/better-auth/better-auth/commit/b461f79c930807485f8c2f4419d0344c1eb595de) feat(email-verification): with otp - [`1ed9256`](https://github.com/better-auth/better-auth/commit/1ed9256d1b2095bf485e0a08aa2fce8cc05c945f) feat(email-verification): with otp - [`7902408`](https://github.com/better-auth/better-auth/commit/79024088e9ff5b0e35c42d3faf78aedd7976bcc6) feat(email-verification): with otp - [`107484c`](https://github.com/better-auth/better-auth/commit/107484c55792faa1d82f782dce51b48d3127ec5a) feat(email-verification): with otp - [`742627f`](https://github.com/better-auth/better-auth/commit/742627fe553476fe61e3aace873ff0823c0bd225) Merge branch 'canary' into feat(email-verification)/with-otp - [`5fcfcec`](https://github.com/better-auth/better-auth/commit/5fcfcec587322a6219a4c0da361a4994f21baa82) feat(email-verification): with otp - [`4242197`](https://github.com/better-auth/better-auth/commit/4242197b711972f5a566ab88d881cf8069854022) Merge branch 'canary' into feat(email-verification)/with-otp ### 📊 Changes **10 files changed** (+623 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/email.mdx` (+129 -3) 📝 `docs/content/docs/plugins/email-otp.mdx` (+14 -0) 📝 `docs/content/docs/reference/options.mdx` (+25 -7) 📝 `packages/better-auth/src/api/index.ts` (+2 -0) 📝 `packages/better-auth/src/api/routes/email-verification.test.ts` (+199 -0) 📝 `packages/better-auth/src/api/routes/email-verification.ts` (+213 -1) 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+20 -0) 📝 `packages/better-auth/src/client/config.ts` (+2 -1) 📝 `packages/core/src/types/init-options.ts` (+17 -0) 📝 `packages/telemetry/src/detectors/detect-auth-config.ts` (+2 -0) </details> ### 📄 Description This PR intros an new function to send email verification with OTP in order to let have otp and verification together. Suggested on #5475 during supabase auth migration. This PR adds the following: - new /verify-email/otp to send email verification with otp together - add related test cases - update docs close https://github.com/better-auth/better-auth/issues/5475 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add link + OTP email verification so users can verify via a link or a code in the same email. Introduces a new POST /verify-email/otp endpoint and the includeOTP option in emailVerification. - **New Features** - New endpoint: POST /verify-email/otp for code-based verification. - Optional OTP in sendVerificationEmail when includeOTP is true. - New config: emailVerification.includeOTP and emailVerification.otpLength. - OTP generation and storage with expiry (defaults to 1 hour). - Client SDK support: client.verifyEmail.otp(...). - Updated docs and comprehensive tests; telemetry now reports includeOTP/otpLength. - **Migration** - Enable emailVerification.includeOTP to send both link and OTP. - Update sendVerificationEmail to handle the optional otp field and include it in the email. - Optionally add a UI that calls client.verifyEmail.otp({ email, otp }) for code entry. <sup>Written for commit bd9173ec11b83908e2c5e3d557cdc40bd31a39ad. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:46:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#6068