Installation
Install Own Auth, configure Postgres, and create the required database tables.
Requirements
- Node.js 18 or later
- A Postgres database, local or hosted
Own Auth also supports Cloudflare Workers. Enable Node.js compatibility in the Worker's Wrangler configuration:
{
"compatibility_flags": ["nodejs_compat"]
}Password hashing uses the same Argon2id format and security parameters in Node.js and Cloudflare Workers, so passwords remain compatible between runtimes.
Install the package
npm install own-authOr with another package manager:
pnpm add own-auth
yarn add own-authSet up your environment
Own Auth reads two environment variables:
# .env
DATABASE_URL=postgres://user:password@localhost:5432/myapp
OWN_AUTH_TOKEN_PEPPER=your-random-secret-stringDATABASE_URL is your Postgres connection string. Any Postgres provider works: local, Supabase, Neon, Railway, RDS, or a VPS running Postgres.
OWN_AUTH_TOKEN_PEPPER adds an extra layer of protection when hashing tokens. Generate a long random string, keep it secret, and use it only on the backend. If you change it, existing sessions, auth links, SMS codes, and API keys become invalid.
To generate a pepper:
openssl rand -base64 32Run migrations
npx own-auth migrateThis creates the tables Own Auth needs in your database:
own_auth_migrationsown_auth_usersown_auth_accountsown_auth_sessionsown_auth_tokensown_auth_sms_otpsown_auth_organisationsown_auth_organisation_membersown_auth_invitationsown_auth_api_keysown_auth_audit_eventsown_auth_rate_limits
All Own Auth tables are prefixed with own_auth_ to avoid conflicts. Your existing application tables are not modified.
Verify
Check that everything is connected:
npx own-auth statusThis prints the database connection status and the latest applied migration version. If it shows Database: connected and Status: current, you are ready.
Database providers
Own Auth works with any Postgres database. Some common setups:
Local Postgres
DATABASE_URL=postgres://postgres:postgres@localhost:5432/myappSupabase
DATABASE_URL=postgres://postgres:[password]@db.[project].supabase.co:5432/postgresNeon
DATABASE_URL=postgres://[user]:[password]@[endpoint].neon.tech/[database]?sslmode=requireRailway
DATABASE_URL=${{Postgres.DATABASE_URL}}AWS RDS
DATABASE_URL=postgres://[user]:[password]@[instance].rds.amazonaws.com:5432/[database]?sslmode=requireUse ?sslmode=require for hosted databases that require TLS.
Next step
Create your auth instance in the Configuration guide.