# Auth for side projects: build it or use a service?

> For a side project, using an authentication service is almost always better than building auth yourself from scratch.

**For a side project, you should not build your own auth from scratch.** Hand-crafting session storage, password hashing, OAuth callbacks, and token verification burns days of setup time on commodity infrastructure instead of your core product. Using a sign-in service gets your app to launch faster while keeping user credentials safe, especially when auth connects directly to your own database.

Every developer considers writing their own login system at least once. It looks like a fun weekend project: a `users` table, a password hash function, and a signed session cookie. But authentication rarely stops there. Within weeks, real user requirements force you to maintain an ever-growing list of edge cases, security fixes, and identity plumbing.

## What building your own auth actually takes

When you decide to write custom authentication, you are not just writing a login form. You are taking on permanent maintenance of an identity stack:

- **Password storage and hashing:** You must choose and tune a hashing algorithm like Argon2id or bcrypt, manage salt generation, and prevent timing attacks during hash comparisons.
- **Session lifecycle:** You need secure, HTTP-only, SameSite cookies to protect against cross-site scripting, alongside session invalidation, token refresh logic, and cleanup jobs for stale database rows.
- **Account recovery:** You must implement password reset flows, secure single-use tokens with tight expiration windows, and transactional delivery that avoids user enumeration attacks.
- **OAuth handshakes:** Supporting social sign-in means managing client IDs, handling redirect callbacks, validating state parameters against CSRF, and refreshing access tokens across provider API changes.
- **Security vulnerabilities:** A subtle mistake in your session parsing or token validation can expose every customer record in your database.

For an early-stage product or side project, this work produces zero competitive advantage. Your visitors do not choose your tool because you wrote custom cryptographic verification; they expect sign-in to work smoothly so they can use your app.

## The comparison: custom auth vs. a managed service

Deciding between building auth yourself and using an existing service usually comes down to control, setup speed, and long-term maintenance.

| Feature | Building your own | Using a sign-in service |
| --- | --- | --- |
| Initial implementation | 1–3 weeks of development | 15–30 minutes of setup |
| Password security | Your responsibility | Built-in password hashing and validation |
| Social logins (Google, GitHub) | Custom OAuth flows per provider | Toggled via CLI or dashboard |
| Environment isolation | Manual seeding and test user mocks | Automatic development and production copies |
| Database storage | Custom schema you design and migrate | Project database with pre-built user tables |
| Account recovery & OTP | Custom email delivery and code expiration | Handled via shared sender or custom SMTP |
| Ongoing maintenance | Constant security reviews and updates | Handled by the service |

Building auth only makes sense when your core product *is* authentication, or when strict compliance rules prevent you from using any third-party infrastructure. For standard web apps, SaaS tools, and side projects, using an existing service saves time without compromising ownership of your data.

## Why data ownership matters for side projects

A common objection to third-party authentication services is the risk of vendor lock-in. Many standalone auth vendors store your user records in their own walled gardens. Exporting your users later can be tedious, and querying user profiles alongside your application data often requires slow HTTP roundtrips or complex webhook syncs.

The ideal middle ground is an authentication service that writes directly to your own database. In thelastapi, adding sign-in automatically attaches a serverless database to your project. All user records live directly inside your project's Postgres instance. You can read user rows, query relational tables with your favorite ORM, and run standard SQL joins across your application schema. To learn more about how databases are structured per project, read [serverless Postgres for side projects: one database per project](https://thelastapi.dev/blog/postgres-database-per-project).

## How sign-in works in thelastapi

With thelastapi, the `auth` resource provides an authentication service tailored to your project. It includes email and password accounts, verification codes, magic links, and social sign-in with Google and GitHub.

To create a new project with authentication and a database:

```bash
vibiz init my-project --resources auth
```

Because adding `auth` brings `database`, your project receives both services under one configuration. There is no separate charge for sign-in today; it is included as part of your project's database.

### Social sign-in without credential setup

Configuring Google OAuth usually requires opening an external developer console, setting up consent screens, and copying client secrets. thelastapi provides shared keys for Google sign-in so you can test immediately:

```bash
vibiz auth providers add google --dev
```

If you prefer using your own credentials for Google or GitHub, you can supply your own client details:

```bash
vibiz auth providers add github --own --client-id Iv1.abc --dev
```

For more details on setting up login methods, read [email and password sign-in with verification codes](https://thelastapi.dev/blog/email-password-sign-in-verification) and our guide on [how to add sign-in to a Next.js app](https://thelastapi.dev/blog/add-sign-in-nextjs-app).

### Separate development and production sign-in

Authentication bugs often happen when local development environments share user databases with production. thelastapi isolates these environments completely. Production and development each have their own sign-in instance and distinct user records. The development copy only trusts `http://localhost:3000`, preventing test credentials from touching live traffic.

Generate your local environment keys with the CLI:

```bash
vibiz dev
```

This writes your development configuration to `.env.development.local`. To learn how this isolation protects your app, see our guide to [separate development and production sign-in](https://thelastapi.dev/blog/separate-dev-production-sign-in) and the documentation on [Keys and environments](https://thelastapi.dev/docs/keys).

## Implementing sign-in inside your application

When your project is created, the environment variables provide everything your backend needs:

- `VIBIZ_AUTH_BASE_URL`: The URL for the sign-in service in the active environment.
- `VIBIZ_AUTH_COOKIE_SECRET`: The secret used to sign session cookies.
- `VIBIZ_AUTH_JWKS_URL` and `VIBIZ_AUTH_PROJECT_ID`: Used for services that verify JWT tokens directly.

If you start with the starter template (`vibiz init --template nextjs-saas`), authentication is already wired up. The helper `currentUser()` in `lib/auth/server.ts` returns the logged-in user, and `/api/auth/*` handles session routes.

If you deploy your app to another host outside thelastapi hosting, you only need to install `@vibiz/app` and load your environment at boot:

```ts
import { vibiz } from '@vibiz/app';

await vibiz.loadEnv();
```

Before your live domain accepts sign-in requests, register it with the CLI so authentication trusts the origin:

```bash
vibiz domains add app.example.com --elsewhere
```

Once the domain's TXT record (`_vibiz.app.example.com`) is in place and verified with `vibiz domains verify app.example.com`, or confirmed by the account owner in the console, sign-in requests from your live app are accepted. You can read more about connecting your custom domains in the [Domains documentation](https://thelastapi.dev/docs/domains) and [Use one service](https://thelastapi.dev/docs/use-one).

## Restricting sign-ups for private projects

Many side projects start as closed alphas or internal tools. Writing invite lists and domain restrictions by hand requires extra schema fields and custom validation logic.

With thelastapi, you can restrict sign-ups to specific corporate domains using a single CLI command:

```bash
vibiz auth domains acme.com,partner.com --dev
```

You can allow up to 50 email domains. To remove restrictions and reopen registration to anyone, clear the list:

```bash
vibiz auth domains none --dev
```

You can also configure magic link lifetimes between 5 and 1440 minutes, customize the application name shown in emails, and require one-time verification codes (`otp`) using our shared email sender. Full configuration parameters are documented in the [Sign-in docs](https://thelastapi.dev/docs/sign-in).

## Making the right choice for your project

Building your own authentication system is an instructive learning exercise, but it is rarely the right choice for a business you want to launch. Every afternoon spent debugging cookie flags, token expiration, and password recovery is time not spent building the core features that make your app valuable.

By using an integrated authentication service that saves data directly to your Postgres database, you keep full ownership of your user data while launching in hours instead of weeks. Create your project, configure your providers, and focus on building what your users actually came for.

## Frequently asked questions

### Can I use thelastapi sign-in if my app is hosted somewhere else?

Yes. You can run your app on any host by adding your domain with `vibiz domains add <domain> --elsewhere` and initializing `@vibiz/app` with `VIBIZ_APP_KEY`. Once the domain's TXT verification record is confirmed or approved by the owner, sign-in will trust the origin.

### Where are my users stored when using the sign-in resource?

Users are stored directly in your project's serverless Postgres database. Because adding `auth` automatically provisions `database`, you can query user records alongside your application data using SQL or your preferred ORM.

### Do I need to create my own OAuth app to offer Google sign-in?

No. thelastapi provides shared keys for Google sign-in so you can enable social login instantly without creating your own Google Cloud console project. GitHub sign-in requires your own OAuth client credentials.

### How much does sign-in cost on thelastapi?

There is no separate charge for sign-in today. It is included as part of your project's database resource while final pricing has not been decided.

---

Published 2026-11-15 · https://thelastapi.dev/blog/auth-build-vs-buy-side-project
