[PR #8528] feat(magic-link): add additionalData support for sendMagicLink #8041

Open
opened 2026-03-13 13:57:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8528
Author: @himself65
Created: 3/9/2026
Status: 🔄 Open

Base: canaryHead: worktree-magic-link-additional-data


📝 Commits (2)

  • a6728b3 feat(magic-link): add additionalData support for sendMagicLink function
  • dcfdc6f test(magic-link): add tests for additionalData feature

📊 Changes

3 files changed (+229 additions, -7 deletions)

View changed files

📝 docs/content/docs/plugins/magic-link.mdx (+52 -1)
📝 packages/better-auth/src/plugins/magic-link/index.ts (+54 -5)
📝 packages/better-auth/src/plugins/magic-link/magic-link.test.ts (+123 -1)

📄 Description

Summary

  • Added additionalData field to the magic link sign-in request body, allowing custom data to be passed from the client to the sendMagicLink function
  • Added additionalDataSchema option accepting a Zod schema for runtime validation and type safety of the additional data
  • When no schema is provided, defaults to Record<string, JsonValue> (unvalidated)
  • Updated documentation with usage examples and configuration details

Ported from #3417 and adapted to the current canary codebase (which has been refactored since the original PR — different imports, extracted body schema, ctx parameter instead of request).

Test plan

  • All 16 existing magic-link tests pass
  • Lint passes
  • Verify additionalData flows through to sendMagicLink callback with and without a custom schema
  • Verify type inference works correctly when additionalDataSchema is provided

🔄 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/8528 **Author:** [@himself65](https://github.com/himself65) **Created:** 3/9/2026 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `worktree-magic-link-additional-data` --- ### 📝 Commits (2) - [`a6728b3`](https://github.com/better-auth/better-auth/commit/a6728b3999584a305adb447e58ca031ab51cf711) feat(magic-link): add additionalData support for sendMagicLink function - [`dcfdc6f`](https://github.com/better-auth/better-auth/commit/dcfdc6fc90759edda535593199e184556ee4d7ae) test(magic-link): add tests for additionalData feature ### 📊 Changes **3 files changed** (+229 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/magic-link.mdx` (+52 -1) 📝 `packages/better-auth/src/plugins/magic-link/index.ts` (+54 -5) 📝 `packages/better-auth/src/plugins/magic-link/magic-link.test.ts` (+123 -1) </details> ### 📄 Description ## Summary - Added `additionalData` field to the magic link sign-in request body, allowing custom data to be passed from the client to the `sendMagicLink` function - Added `additionalDataSchema` option accepting a Zod schema for runtime validation and type safety of the additional data - When no schema is provided, defaults to `Record<string, JsonValue>` (unvalidated) - Updated documentation with usage examples and configuration details Ported from #3417 and adapted to the current canary codebase (which has been refactored since the original PR — different imports, extracted body schema, `ctx` parameter instead of `request`). ## Test plan - [x] All 16 existing magic-link tests pass - [x] Lint passes - [x] Verify `additionalData` flows through to `sendMagicLink` callback with and without a custom schema - [x] Verify type inference works correctly when `additionalDataSchema` is provided --- <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 13:57:52 -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#8041