Skip to content

Migrate from NextAuth v5 to Better Auth #2349

@brianmjohnson

Description

@brianmjohnson

I've completed a full migration of Typebot from NextAuth v5 to Better Auth in a private fork and would be happy to contribute this upstream if there's interest.

What's Been Done

  • Full replacement of NextAuth v5 with Better Auth
  • Cross-subdomain SSO support via configurable cookie domain
  • OAuth provider configuration via environment variables
  • Account schema migration (field name updates for Better Auth compatibility)
  • Workspace auto-provisioning hooks for new users
  • Server-side auth provider computation (vs build-time env vars)

Why Better Auth?

  • Simpler API with less boilerplate
  • Built-in database adapters with better TypeScript support
  • More flexible session management
  • Active development and modern architecture
  • Easier cross-subdomain authentication

The Challenge

I attempted to cherry-pick my commits into a clean PR, but ran into significant conflicts. Since my fork diverged at v3.15.0, you've restructured the auth code into packages/auth/ while my migration was based on the previous apps/builder/src/features/auth/ structure.

This means a direct cherry-pick isn't feasible - it would require either:

  1. Rewriting the migration against your current packages/auth/ structure
  2. Collaborative approach where I provide the implementation details and someone familiar with the new structure adapts it

Next Steps

If there's interest in Better Auth for Typebot, I'm happy to:

  • Share my implementation for reference
  • Rewrite the migration against current main and submit a PR
  • Collaborate on the approach if you have specific requirements

Let me know if this is something you'd consider!


Migration has been running in production on a private fork.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Backlog ☁️

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions