Deploy a Next.js app with a database and sign-in in one command
Deploy a Next.js app with a database and sign-in in one command using vibiz deploy, with serverless Postgres and auth provisioned automatically.
On this page 7 sections
You can deploy a Next.js app with a database and sign-in in one command by running vibiz deploy after initializing your project with the CLI. thelastapi provisions your web hosting, serverless Postgres database, user sign-in, and analytics together under a single project configuration. You build and test locally with an isolated database branch via vibiz dev, write your Next.js application logic, and deploy straight to production without managing separate infrastructure accounts.
Here is how the automated provisioning works, how local development stays isolated from live data, and how to deploy and maintain your application.
What happens when you initialize a project
Building a full-stack Next.js project traditionally requires stitching together four separate systems: a hosting platform, a managed database host, an authentication vendor, and an analytics tool. Each service demands its own account, access keys, billing dashboard, and environment variable configuration.
thelastapi consolidates these core requirements into a single project setup. From an empty directory or an existing repository, you start with the CLI:
mkdir acme-app && cd acme-app
vibiz init "Acme App" --template nextjs-saasWhen you run vibiz init, the platform automatically provisions four resources:
- Hosting: Compiles and serves your Next.js app at
https://<slug>.vibiz.app. - Database: Creates a serverless Postgres database ready for your schemas and queries.
- Auth: Pre-configures end-user sign-in supporting Google and GitHub.
- Analytics: Tracks visits and pageviews without cookie banners.
The command creates a local ./vibiz.json file storing your project ID. If you already have a Next.js codebase, omitting the --template flag links your existing files to the new backend resources.
Resource provisioning runs in the background. Each resource transitions from pending to provisioning to ready. You can check their setup status at any time:
vibiz statusFor a step-by-step introduction to installing the CLI and logging in through your browser, check the Quickstart documentation.
How local development works with vibiz dev
Connecting your local machine to cloud databases can risk overwriting production data or requires running heavy container setups locally.
To solve this, thelastapi creates an isolated development environment for your local machine:
vibiz devThe vibiz dev command generates a .env.development.local file containing:
- A dedicated development database branch with your production schema and tables, but none of the live production rows.
- Sign-in credentials pre-configured to trust
http://localhost:3000. - An isolated development AI API key.
After the development environment file is written, start your standard Next.js local server:
npm run devYour Next.js server actions and API routes can now run database queries against Postgres. When you define your data models, standard ORMs work directly with the provided connection string. For complete setup patterns, read our walkthrough on how to Use Postgres from Next.js with Drizzle or Prisma.
How to deploy your Next.js app to production
When you are ready to publish, deployment takes a single command from your project root:
vibiz deploy -m "Initial release"The CLI scans your directory, calculates SHA-1 content hashes for every file, and checks which files the platform already stores. Files that the host already has are never uploaded twice. Once the missing files are uploaded, the build server compiles your Next.js application and deploys it live.
Uploading changed files...
Deployment dep_01k ready
Live at https://acme-app.vibiz.appFiles excluded from deployment
To protect your credentials and minimize upload sizes, the CLI automatically ignores unnecessary or sensitive directories:
- Build output directories (
.next,dist,.turbo) - Local dependency folders (
node_modules) - Version control metadata (
.git) - Project configuration (
vibiz.json) - Local environment files (
.env*) - Credentials and private keys (
*.pem,id_rsa,.npmrc)
Because .env* files are excluded, production runs exclusively using the production variables maintained by thelastapi. The deployed server automatically receives the live database URL and production authentication keys.
Build limits and hosting costs
Hosting and builds are recorded in usage at $0 today. Every project receives an allowance of 30 builds per UTC day. Reaching this cap returns a 429 rate_limited error until the reset window. Each deployment accepts up to 10,000 files, with an individual file limit of 50 MB.
For a broader breakdown of hosting expenses for early-stage software, see our guide on The cheapest way to host a website and database for a side project.
How preview deploys and rollbacks work
If you want to review changes before publishing them to visitors, build a preview deployment:
vibiz deploy --previewA preview deployment generates an isolated preview URL where you can verify layout, test authentication, and validate server responses. When you are ready to make the preview live, promote it to production:
vibiz promote dep_01kPromoting a deployment switches your live production traffic to that build.
Reverting live releases
If a production update introduces an application error, you can revert to the previous working deployment:
vibiz rollbackYou can review past deployments with timestamps and file changes:
vibiz versionsImportant: Code rollbacks switch your running application build instantly, but the database is not rolled back. Column additions, deleted tables, and existing data rows stay as they are now. Make sure that schema updates remain backward-compatible with the previous code version.
For more technical details on file manifests and build mechanics, visit the Hosting guide. If you manage deployments through automated pipelines, see Deploy from CI with one command and one key.
Adding a custom domain
Every app is reachable immediately at its free https://<slug>.vibiz.app address. When you want to attach your own domain name, connect it through the CLI:
vibiz domains add shop.example.comThe CLI returns the exact DNS records needed for your provider:
| Domain type | DNS Record | Host / Name | Target Value |
|---|---|---|---|
Subdomain (shop.example.com) | CNAME | shop | cname.vibiz.app |
Apex domain (example.com) | A | @ | IP from records list |
Apex redirect (www.example.com) | CNAME | www | cname.vibiz.app |
Connecting an apex domain like example.com automatically configures www.example.com as a permanent redirect to your root site.
HTTPS certificates activate on their own as soon as DNS propagation completes. In addition, domains added by the account owner are trusted for sign-in automatically, so Google and GitHub OAuth callbacks accept requests without extra verification steps. See Domains for complete DNS details.
Monitoring health and exporting your data
Once your app is live, you can monitor its operational status across the account directly from your terminal:
vibiz healthHealth checks run automatically every hour. They verify whether your primary address answers within 10 seconds, detect failed builds, identify JavaScript error spikes, and check domain certificate validity. For full dashboard analytics, consult Mission Control and health checks.
If you ever choose to run your stack elsewhere, the platform provides complete data portability:
vibiz exportThe command packages your project into an archive containing:
<slug>-production-code.zip: The exact source code as uploaded.<slug>-production-database.sql.gz: A consistent Postgres snapshot with tables, indexes, and rows ready forpsql.VIBIZ-EXPORT.md: A reference describing every service and environment variable your app requires.
See Export for full backup options. To get started building, create your account at thelastapi.dev/start, log in via the CLI, and run vibiz init.
Frequently asked questions
Does rolling back a deployment also revert my database changes?
No. Rolling back switches your application code back to the previous deployment, but the database is not rolled back. Schema migrations and stored data remain untouched, so database changes should stay backward-compatible.
Are local .env files uploaded when I run vibiz deploy?
No. The CLI ignores all `.env*` files, `.git`, `node_modules`, and build output directories during deployment. Your production deployment automatically reads the production database URLs and sign-in keys configured for your project.
How many builds can I run each day?
Projects have a limit of 30 builds per UTC day. You can view your current build usage by running `vibiz status` or querying `GET /v1/usage`.
What sign-in providers work with the default auth setup?
Sign-in supports Google and GitHub out of the box, with redirection domains automatically trusted for your project's primary domain and local development server.