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

Open
opened 2026-04-17 23:14:42 -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: mainHead: docs/clerk-migration-guide-password-hashing-step


📝 Commits (4)

  • 320a45d docs: add password hashing step to clerk migration guide
  • 394466c Update docs/content/docs/guides/clerk-migration-guide.mdx
  • 5a2b330 Apply suggestions from code review
  • 05e5b73 Merge branch 'main' 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 “Change password hashing algorithm” step to the Clerk migration guide so Better Auth uses bcrypt for migrated passwords. Fixes “Invalid password” errors for credential logins after migration.

  • Migration
    • Install bcrypt and @types/bcrypt; use bcryptjs on Cloudflare Workers.
    • Update emailAndPassword.password to hash and verify with bcrypt (code sample included).
    • Optional: require a password reset to re-hash with scrypt.

Written for commit 05e5b731e1. Summary will update 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:** `main` ← **Head:** `docs/clerk-migration-guide-password-hashing-step` --- ### 📝 Commits (4) - [`320a45d`](https://github.com/better-auth/better-auth/commit/320a45de651a23685a3e76c5116993f32098468a) docs: add password hashing step to clerk migration guide - [`394466c`](https://github.com/better-auth/better-auth/commit/394466c65f381d29921ca60a8313c6a581d9fa0f) Update docs/content/docs/guides/clerk-migration-guide.mdx - [`5a2b330`](https://github.com/better-auth/better-auth/commit/5a2b330e440fbc36babedb84fe7eadb33da47233) Apply suggestions from code review - [`05e5b73`](https://github.com/better-auth/better-auth/commit/05e5b731e180064e9349107d116f3b449458b785) Merge branch 'main' 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 “Change password hashing algorithm” step to the Clerk migration guide so Better Auth uses `bcrypt` for migrated passwords. Fixes “Invalid password” errors for credential logins after migration. - **Migration** - Install `bcrypt` and `@types/bcrypt`; use `bcryptjs` on Cloudflare Workers. - Update `emailAndPassword.password` to hash and verify with `bcrypt` (code sample included). - Optional: require a password reset to re-hash with `scrypt`. <sup>Written for commit 05e5b731e180064e9349107d116f3b449458b785. Summary will update 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-04-17 23:14:42 -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#32431