docs/content/docs/reference/contributing.mdx
Thank you for your interest in contributing to Better Auth! This guide is a concise guide to contributing to Better Auth.
Before diving in, here are a few important resources:
To get started with development:
<Callout type="warn"> Make sure you have <Link href="https://nodejs.org/en/download">Node.JS</Link>{" "} installed, preferably on LTS. </Callout> <Steps> <Step> ### 1. Fork the repositoryVisit [https://github.com/better-auth/better-auth](https://github.com/better-auth/better-auth)
Click the "Fork" button in the top right.
```bash
# Replace YOUR-USERNAME with your GitHub username
git clone https://github.com/YOUR-USERNAME/better-auth.git
cd better-auth
```
Make sure you have <Link href="https://pnpm.io/installation">pnpm</Link> installed!
```bash
pnpm install
```
Copy the example env file to create your new `.env` file.
```bash
cp -n ./docs/.env.example ./docs/.env
```
Once you have an idea of what you want to contribute, you can start making changes. Here are some steps to get started:
<Steps> <Step> ### 1. Create a new branch```bash
# Add upstream remote (if not already added)
git remote add upstream https://github.com/better-auth/better-auth.git
# Make sure you're on main
git checkout main
# Pull latest changes
git pull upstream main
# Create and switch to a new branch
git checkout -b feature/your-feature-name
```
Start the development server:
```bash
pnpm dev
```
To start the docs server:
```bash
pnpm -F docs dev
```
* Make your changes to the codebase.
* Write tests if needed. (Read more about <Link href="/docs/reference/contributing#testing">testing</Link>)
* Update documentation. (Read more about <Link href="/docs/reference/contributing#documentation">documenting</Link>)
good first issueWe welcome contributions to support more frameworks:
We use Vitest for testing. Place test files next to the source files they test:
import { describe, it, expect } from "vitest";
import { getTestInstance } from "./test-utils/test-instance";
describe("Feature", () => {
it("should work as expected", async () => {
const { client } = await getTestInstance();
// Test code here
expect(result).toBeDefined();
});
});
The test instance helper now includes improved async context support for managing user sessions:
const { client, runWithUser, signInWithTestUser } = await getTestInstance();
// Run tests with a specific user context
await runWithUser("[email protected]", "password", async (headers) => {
// All client calls within this block will use the user's session
const response = await client.getSession();
// headers are automatically applied
});
// Or use the test user with async context
const { runWithDefaultUser } = await signInWithTestUser();
await runWithDefaultUser(async (headers) => {
// Code here runs with the test user's session context
});
Don't hesitate to ask for help! You can:
Thank you for contributing to Better Auth!