Hi, we really appreciate your interest in contributing to Better Auth. This guide will help you get started. Your contributions make Better Auth even better for everyone. Before you begin, please take a moment to review the following guidelines.
By participating in this project, you agree to abide by our Code of Conduct.
-
Fork the repository and clone it locally:
git clone https://github.com/your-username/better-auth.git cd better-auth -
Install Node.js (LTS version recommended)
Note: This project is configured to use nvm to manage the local Node.js version, as such this is the simplest way to get you up and running.
Once installed, use:
nvm install nvm use
Alternatively, see Node.js installation for other supported methods.
-
Install pnpm
Note: This project is configured to manage pnpm via corepack. Once installed, upon usage you’ll be prompted to install the correct pnpm version
Alternatively, use
npmto install it:npm install -g pnpm
-
Install project dependencies:
pnpm install
-
Build the project:
pnpm build
Bug fixes and new features must include tests.
Run the full test suite:
pnpm testOr filter by file or directory:
pnpm vitest packages/better-auth/src/plugins/organization --runUse getTestInstance() from better-auth/test to set up test instances:
import { getTestInstance } from "better-auth/test";
const { client, auth } = await getTestInstance({
plugins: [organization()],
});Adapter tests require Docker containers. Start them before running adapter tests:
Note: On macOS, the MSSQL container requires Rosetta emulation and at least 2 GB of allocated memory.
docker compose up -dEnd-to-end tests live in e2e/ and are split into three suites: smoke, adapter,
and integration.
When writing a test for a specific GitHub issue, add a @see comment:
/**
* @see https://github.com/better-auth/better-auth/issues/1234
*/
it("should handle the previously broken behavior", async () => {
// ...
});The documentation site lives in docs/ and content is organized under docs/content/docs/ by topic.
To run the docs locally:
pnpm -F docs devWhen making changes to public APIs, please update the relevant documentation.
Before opening an issue, search existing issues to avoid duplicates. We provide templates to help you get started.
Use the bug report template. Provide a clear description of the bug with steps to reproduce and a minimal reproduction.
New features start with discussion. Open a feature request describing the problem, your proposed solution, and how it would benefit the project. This gives us room to align on scope and API shape before anyone writes code.
Do not open a public issue for security vulnerabilities. Email security@better-auth.com instead. See SECURITY.md for details.
Note
For new features, please open an issue first to discuss before moving forward. We do not review large feature PRs opened without going through an issue first.
Lefthook runs linting, formatting, and spell checking in parallel on every commit. Additional checks like dependency linting (knip), type checking, and tests run in CI.
To skip a specific hook by command name, use LEFTHOOK_EXCLUDE:
LEFTHOOK_EXCLUDE=spell git commit -m "your message"Run pnpm typecheck and make sure it passes before opening your PR.
mainis the stable track. It ships bug fixes, security work, additive improvements, and behavior changes that do not require user action. New capabilities can land here too as long as they are well-tested, non-breaking, and safe to adopt immediately.nextis the beta track. It ships new features, refactors, and breaking changes, after a beta cycle that gives users a window to adapt.
Automation moves PRs with minor or major changesets from main to next
for you.
PRs that touch packages/** need a changeset before they can be merged. Run
pnpm changeset when you're ready to submit, or update it during review if
your changes evolve. The CLI walks you through picking the affected packages,
a bump type, and a short user-facing description for the changelog. Commit
the generated file with your PR.
Pick the bump type based on user impact:
patchfor bug fixes and additive changes existing users don't need to know about.minorormajorfor anything existing users need to be aware of (see Branch Targeting).
If you're not sure whether your change needs one, a maintainer will handle it before merge.
-
Open a pull request against the
mainbranch. -
PR titles must follow the Conventional Commits format, with an optional scope for the affected package or feature:
`feat(scope): description` or `fix(scope): description` or `perf: description` or `docs: description` or `chore: description` etc.- The subject must start with a lowercase letter.
- Use
docswhen changes are confined todocs/. - Append
!for breaking changes (e.g.feat(scope)!: description). These go throughnext, notmain.
-
In your PR description:
- Clearly describe what you changed and why
- Reference related issues (e.g. "Closes #1234")
- List any potential breaking changes
- Add screenshots for UI changes
We welcome AI-assisted contributions, whether code or issue reports, as long as they solve a real problem. Code must follow our coding standards and include appropriate tests and documentation. You should also review and understand what you're submitting well enough to discuss it. PRs and issues that do not meet these guidelines will be closed.