Skip to main content

Overview

Better Auth Studio provides powerful bulk operations for quickly populating your database with test data. This is essential for development, testing, and demonstrating your authentication system.

Bulk User Seeding

Overview

Create multiple test users at once with customizable attributes.

Accessing Bulk User Operations

1

Navigate to Users

Go to the Users page in the studio dashboard.
2

Open Bulk Actions

Click the Bulk Operations or Seed Users button in the toolbar.
3

Configure Settings

Set the number of users and configure user attributes.
4

Execute

Click Generate Users to create the test users.

User Generation Options

Range: 1-1000 users per operation
{
  "count": 50,
  "message": "Generate 50 test users"
}
Generating large numbers of users (500+) may take several seconds and could impact database performance.
Options:
{
  "emailPattern": "sequential",
  "domain": "example.com"
}
Options:
  • Same password for all users
  • Random secure passwords
  • Custom password pattern
{
  "password": "testPassword123",
  "hashPasswords": true
}
For testing, use the same password for all users to simplify login testing.
Configurable Fields:
  • Email verification status
  • Account creation date
  • User roles
  • Custom metadata
{
  "emailVerified": true,
  "createdAt": "2024-01-01",
  "role": "user"
}

Example: Generate Test Users

{
  "count": 10,
  "emailPattern": "sequential",
  "domain": "test.com",
  "password": "password123",
  "emailVerified": false
}

Generated User Data

Bulk operations create users with:
{
  id: "generated-uuid",
  email: "[email protected]",
  emailVerified: false,
  name: "Test User 1",
  image: null,
  createdAt: new Date(),
  updatedAt: new Date(),
  // Password is automatically hashed
}

Bulk Organization Seeding

Overview

Create multiple organizations with associated teams and members.

Accessing Bulk Organization Operations

1

Navigate to Organizations

Go to the Organizations page in the studio dashboard.
2

Open Bulk Seeding

Click the Bulk Operations or Seed Organizations button.
3

Configure Structure

Set number of organizations, teams per org, and members per team.
4

Execute

Click Generate Organizations to create the structure.

Organization Generation Options

Range: 1-100 organizations per operation
{
  "count": 10,
  "message": "Generate 10 test organizations"
}
Options:
  • Sequential: Organization 1, Organization 2
  • Random company names: Acme Corp, TechStart Inc
  • Custom prefix: MyCompany 1, MyCompany 2
{
  "namePattern": "random",
  "prefix": "Test Org"
}
Auto-generated from name:
  • Acme Corpacme-corp
  • TechStart Inctechstart-inc
{
  "name": "Acme Corp",
  "slug": "acme-corp"
}
Slugs are automatically made unique by appending numbers if conflicts occur.
Configurable Fields:
  • Logo URL
  • Description
  • Creation date
  • Custom metadata
{
  "logo": "https://example.com/logo.png",
  "metadata": {
    "industry": "Technology",
    "size": "50-100"
  }
}

Team Generation

Range: 0-20 teams per organization
{
  "teamsPerOrg": 3,
  "teamNames": ["Engineering", "Marketing", "Sales"]
}
Options:
  • Default teams (Engineering, Sales, Marketing, etc.)
  • Custom team names
  • Random team names
{
  "teamPattern": "default",
  "customTeams": ["DevOps", "Design", "Support"]
}

Member Assignment

Range: 0-50 members per team
{
  "membersPerTeam": 5,
  "assignmentStrategy": "random"
}
Available Roles:
  • Owner
  • Admin
  • Member
{
  "defaultRole": "member",
  "ownerCount": 1,
  "adminCount": 2
}

Example: Generate Organizations

{
  "organizationCount": 5,
  "teamsPerOrg": 2,
  "membersPerTeam": 3,
  "namePattern": "sequential"
}

Performance Considerations

Database Load

Large Operations: Generating hundreds of users/organizations can impact database performance.
Best Practices:
1

Start small

Test with 10-20 records first to verify configuration.
2

Increase gradually

Scale up to larger numbers once you’ve verified the setup.
3

Monitor performance

Watch database CPU/memory during large operations.
4

Use batching

For very large datasets, run multiple smaller operations.

Operation Times

Typical execution times:
RecordsEstimated Time
10 users<1 second
100 users2-5 seconds
500 users10-20 seconds
1000 users30-60 seconds
Password Hashing: The majority of time is spent securely hashing passwords. This is intentional for security.

Use Cases

Development Testing

Quickly populate local database with realistic test data.

Demo Environments

Create impressive demos with realistic user bases.

Load Testing

Generate large datasets to test performance and scalability.

Feature Testing

Test features like pagination, search, and filtering with real data.

Data Cleanup

Deleting Bulk Data

To remove seeded data:
1

Filter seeded records

Use search/filter to find bulk-generated records.
2

Select records

Use multi-select to choose records for deletion.
3

Bulk delete

Click Delete Selected to remove multiple records at once.
Irreversible: Bulk delete operations cannot be undone. Always backup production data before bulk operations.

Database Reset

For complete cleanup during development:
# Prisma
prisma migrate reset

# Drizzle
pnpm drizzle-kit push

# SQLite
rm better-auth.db

Best Practices

Development Environment

Generate data that mimics production for better testing:
  • Realistic email domains
  • Varied user attributes
  • Proper role distribution
  • Distributed creation dates
Add metadata to identify bulk-generated records:
{
  "metadata": {
    "source": "bulk_seed",
    "seededAt": "2024-03-03",
    "batch": "dev-001"
  }
}
Keep track of what you’ve seeded:
  • Number of records
  • Configuration used
  • Purpose of the data
  • Date seeded

Testing Scenarios

{
  "count": 150,
  "comment": "Test pagination with 3 pages of 50 users each"
}
{
  "emailPattern": "random",
  "count": 100,
  "comment": "Diverse emails for search functionality testing"
}
{
  "roles": {
    "admin": 5,
    "user": 45,
    "moderator": 10
  },
  "comment": "Mixed roles for permission testing"
}

Limitations

Current Limitations

  • Maximum users per operation: 1000
  • Maximum organizations per operation: 100
  • Maximum teams per organization: 20
  • Maximum members per team: 50

Working Around Limits

For larger datasets:
1

Run multiple operations

Execute several bulk operations sequentially.
2

Use database scripts

For very large datasets (10k+ records), consider direct database seeding scripts.
3

Implement custom seeding

Create custom seeding scripts using Better Auth APIs.

Next Steps

User Management

Learn about managing users in the studio

Organizations

Explore organization management features

CLI Usage

Master the CLI for efficient workflows

Troubleshooting

Common issues and solutions

Build docs developers (and LLMs) love