[PR #6693] docs: add password hashing step to clerk migration guide #6830

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6693
Author: @tsatsujnr139
Created: 12/11/2025
Status: 🔄 Open

Base: canaryHead: docs/clerk-migration-guide-password-hashing-step


📝 Commits (3)

  • b1b3953 docs: add password hashing step to clerk migration guide
  • 9030ea8 Update docs/content/docs/guides/clerk-migration-guide.mdx
  • 50f4fc5 Merge branch 'canary' into docs/clerk-migration-guide-password-hashing-step

📊 Changes

1 file changed (+39 additions, -0 deletions)

View changed files

📝 docs/content/docs/guides/clerk-migration-guide.mdx (+39 -0)

📄 Description

Users following the Clerk migration guide would encounterERROR [Better Auth]: BetterAuthError [BetterAuthError: Invalid password errors when trying to authenticate migrated users with credential logins. This occurred because:

  • Better Auth uses scrypt algorithm by default for password hashing
  • Clerk uses bcrypt algorithm for password hashing
  • When passwords are migrated from Clerk, they remain as bcrypt hashes
  • Without configuring Better Auth to use bcrypt, password verification fails with an invalid hash error

Solution

Added a new step in the migration guide that:

  1. Explains the difference between Better Auth's default scrypt and Clerk's bcrypt algorithms
  2. Provides instructions to install bcrypt and @types/bcrypt packages
  3. Shows how to configure Better Auth's emailAndPassword.password options to use bcrypt for both hashing and verification
  4. Mentions an alternative approach (password reset flow) for users who prefer to re-hash passwords with scrypt

Impact

  • Users can now successfully authenticate migrated users with credential logins without errors
  • Provides clear guidance on handling password hashing algorithm differences during migration
  • Prevents confusion and authentication failures after migration

Changes

  • Added new step "Change password hashing algorithm" after the "Verify the migration" step
  • Includes code examples for installing dependencies and configuring the auth instance

This ensures users can complete the migration end-to-end and authenticate migrated credential users immediately.


Summary by cubic

Adds a new step to the Clerk migration guide to configure Better Auth to use bcrypt for migrated passwords. Prevents “Invalid password” errors for credential logins after migration.

  • Migration
    • Install bcrypt and @types/bcrypt. Use bcryptjs in Cloudflare Workers.
    • Configure emailAndPassword.password hash/verify to use bcrypt.
    • Optional: require a password reset to re-hash with scrypt.

Written for commit 50f4fc5098a7f731522cdaa7bd5bd21f8e8d2575. 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/6693 **Author:** [@tsatsujnr139](https://github.com/tsatsujnr139) **Created:** 12/11/2025 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `docs/clerk-migration-guide-password-hashing-step` --- ### 📝 Commits (3) - [`b1b3953`](https://github.com/better-auth/better-auth/commit/b1b3953e10d8ae90ee48d518766e30d8d67095f8) docs: add password hashing step to clerk migration guide - [`9030ea8`](https://github.com/better-auth/better-auth/commit/9030ea8300848fb68f2eb3e224a66838891685c5) Update docs/content/docs/guides/clerk-migration-guide.mdx - [`50f4fc5`](https://github.com/better-auth/better-auth/commit/50f4fc5098a7f731522cdaa7bd5bd21f8e8d2575) Merge branch 'canary' into docs/clerk-migration-guide-password-hashing-step ### 📊 Changes **1 file changed** (+39 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/guides/clerk-migration-guide.mdx` (+39 -0) </details> ### 📄 Description Users following the Clerk migration guide would encounter`ERROR [Better Auth]: BetterAuthError [BetterAuthError: Invalid password` errors when trying to authenticate migrated users with credential logins. This occurred because: - Better Auth uses `scrypt` algorithm by default for password hashing - Clerk uses `bcrypt` algorithm for password hashing - When passwords are migrated from Clerk, they remain as bcrypt hashes - Without configuring Better Auth to use bcrypt, password verification fails with an invalid hash error ### Solution Added a new step in the migration guide that: 1. Explains the difference between Better Auth's default `scrypt` and Clerk's `bcrypt` algorithms 2. Provides instructions to install `bcrypt` and `@types/bcrypt` packages 3. Shows how to configure Better Auth's `emailAndPassword.password` options to use bcrypt for both hashing and verification 4. Mentions an alternative approach (password reset flow) for users who prefer to re-hash passwords with scrypt ### Impact - Users can now successfully authenticate migrated users with credential logins without errors - Provides clear guidance on handling password hashing algorithm differences during migration - Prevents confusion and authentication failures after migration ### Changes - Added new step "Change password hashing algorithm" after the "Verify the migration" step - Includes code examples for installing dependencies and configuring the auth instance This ensures users can complete the migration end-to-end and authenticate migrated credential users immediately. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a new step to the Clerk migration guide to configure Better Auth to use bcrypt for migrated passwords. Prevents “Invalid password” errors for credential logins after migration. - **Migration** - Install bcrypt and @types/bcrypt. Use bcryptjs in Cloudflare Workers. - Configure emailAndPassword.password hash/verify to use bcrypt. - Optional: require a password reset to re-hash with scrypt. <sup>Written for commit 50f4fc5098a7f731522cdaa7bd5bd21f8e8d2575. 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 13:13:09 -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#6830