workflowstacks
saas-starter

better-auth: Easy SaaS Auth

Get comprehensive authentication with better-auth. For SaaS founders.
29,504 stars2,784 forksTypeScriptHealth Score 8/10Updated 8/9/2026100% free · open source
What it does

Better-auth provides a comprehensive authentication system for SaaS applications, handling user registration, login, and authorization in a secure and scalable manner.

Install / run
npm install @better-auth/core
When to use it
  • When building a SaaS application that requires secure user authentication and authorization
  • When needing to integrate multiple authentication providers, such as Google, Facebook, or GitHub
  • When requiring a customizable and extensible authentication system to fit specific business needs
Quick start
  1. 1Create a new instance of the BetterAuth class, passing in your application's configuration: `const betterAuth = new BetterAuth({ clientId: 'your_client_id', clientSecret: 'your_client_secret' })`
  2. 2Configure the authentication providers using the `betterAuth.providers` object, for example: `betterAuth.providers.google = { clientId: 'your_google_client_id', clientSecret: 'your_google_client_secret' }`
  3. 3Implement the authentication flow using the `betterAuth.authenticate()` method, which returns a promise that resolves to an authentication result object
  4. 4Use the `betterAuth.authorize()` method to check if a user has permission to access a specific resource or perform a specific action
  5. 5Refer to the example configuration file `config.example.ts` in the BetterAuth repository for a complete example of how to configure the library
Ready-to-paste prompt
To authenticate a user with Google, use the following code: `betterAuth.authenticate('google').then((result) => console.log(result))`
Heads up: Make sure to handle errors properly when using the `betterAuth.authenticate()` and `betterAuth.authorize()` methods, as they can throw exceptions if the authentication or authorization process fails, for example: `betterAuth.authenticate('google').catch((error) => console.error(error))`
Saves to your device

Topics

authentication
iam
oauth
oauth2
oidc
sso
stripe
typescript
How better-auth: Easy SaaS Auth works
Codeflow
Free to inspect

Better-auth: Easy SaaS Auth is a very large TypeScript project (~301k lines across 1397 code files, plus 168 test files). Setup is light: installs like a normal app. Reading the code is optional. Last commit this month, MIT license, has a test suite.

Size
Very large codebase
~301k lines · 1397 code files · days to read — use, don't read
Setup
One-command install
Installs like a normal app. Reading the code is optional.
Runs on
Node.js · Docker
No API keys detected
TypeScript 100%
Where to start reading
  1. 1
    README.md
    Start here — what it does and how to install it
  2. 2
    AGENTS.md
    The instructions the AI actually follows
  3. 3
    package.json
    Dependencies and the commands it exposes
  4. 4
    demo/electron/.gitignore
    A worked example — copy this to get going
What's in each folder
packages/Sub-packages / plugins1160 files
docs/Documentation435 files
demo/Examples you can copy320 files
patches/Patches1 files
e2e/Tests — proof it works177 files
.github/CI / automation (GitHub Actions)30 files
.changeset/Tool / agent settings17 files
test/Tests — proof it works12 files
READMEHas testsDocumentedCI checksDocker readyExamples includedMIT licenseUpdated this month
Quick Actions
Details
Creator
better-auth
Language
TypeScript
Category
saas-starter
Published
5/19/2024

Are you the creator of this tool? Claim your listing → and earn 85% of every sale.