Deploying a Multi-Tenant Laravel SaaS on Laravel Cloud
By ERAG··7 min read

I deployed my SaaS Laravel starter kit to Laravel Cloud. It's a Laravel 13 app with multi-tenancy, and every tenant gets its own database. Cloud gave the app this address:
saas-laravel-starter-kit-local-tteeoy.laravel.cloudIt didn't work on the first try. The build failed once, and after that the site showed a completely blank white page. This post covers what I set up, what went wrong, and the config that fixed it. If you deploy a multi-tenant app to Cloud, the blank page is the part to read first.
Laravel gave me Cloud credits for this post, but the views are my own.
Why I chose Laravel Cloud
Laravel Cloud is built by the official Laravel team, so it fits Laravel apps naturally. My SaaS starter kit and other Laravel applications run on it with very little setup.
I chose it because I can set up real-time features with Laravel Reverb, run queue workers, and deploy, all in an easy way, without managing servers myself.
For this first deploy I kept things small: the app and one database.
Creating the app
Cloud's onboarding has four steps:
- Connect your source control provider.
- Select a repository.
- Create your application.
- Add resources (optional).
I connected GitHub and picked the repository for the Vue edition of my kit, the-erag/saas-laravel-starter-kit-vue. On the "Create your application" step I used these settings:
| Setting | Value |
|---|---|
| Application name | saas-laravel-starter-kit |
| Region | US East (Virginia) |
| Run as a static website | Off |

The last step offers three resources, which Cloud creates in the same region as the app:
- Database: Laravel MySQL
- Cache: Laravel Valkey
- WebSockets: Laravel Reverb
I checked only Database with Laravel MySQL and clicked "Deploy your application". While the first deployment waited to start, Cloud showed that the database cluster saas_laravel_starter_kit_production was provisioning.


Why MySQL and not SQLite
I first wanted to use SQLite. On Laravel Cloud the filesystem resets on every deploy, so a SQLite file would be lost. I used a Laravel Cloud MySQL database instead.
My kit also creates a separate database for every tenant, so MySQL fits it better anyway.
I tested the kit with both databases on Laravel Cloud: MySQL and Serverless Postgres. Both worked, including creating a tenant with its own database. For MySQL I used DB_CONNECTION=mysql. For Postgres I used DB_CONNECTION=pgsql with the Cloud Postgres database attached.
Problem 1: the build failed
The first deployment failed during the build. Composer installed the packages and generated the autoloader. Then package:discover failed:
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
{"message":"Class \"Spatie\\LaravelTypeScriptTransformer\\TypeSc…
ERROR: failed to build: exit status 1The build screen cuts the message off, but the class name points at the TypeScript transformer.

The cause was in my kit. The Vue, React and Svelte editions use spatie/laravel-typescript-transformer to generate TypeScript types from PHP data classes. That package is in require-dev, so it's missing after composer install --no-dev, which is how the production build installs packages.
My kit still listed its TypeScriptTransformerServiceProvider in bootstrap/providers.php. That provider extends a class from the missing package. So Laravel tried to load it, couldn't find the parent class, and the build stopped.
The fix: I removed the provider from bootstrap/providers.php and registered it in AppServiceProvider, only when the package is installed:
use Spatie\LaravelTypeScriptTransformer\TypeScriptTransformerApplicationServiceProvider;
public function register(): void
{
// The TypeScript transformer is a dev dependency, so it is missing
// after `composer install --no-dev` (e.g. on Laravel Cloud / Forge).
if (class_exists(TypeScriptTransformerApplicationServiceProvider::class)) {
$this->app->register(TypeScriptTransformerServiceProvider::class);
}
}On my machine, where dev dependencies are installed, nothing changes. In production the provider is skipped. I made the same change in the React and Svelte editions and pushed it as "fix(kits): load TypeScript transformer only when installed".
The deployment with that fix built in 46 seconds. Its build steps finished in this order: preparing the build environment, running build commands, and pushing the application. Cloud's deployment docs explain what runs in each step if you need to change the build or deploy commands.

Environment variables
These are the environment variables the app had after the first deploy. I've left out secrets.
APP_ENV=production
APP_DEBUG=false
APP_URL=https://saas-laravel-starter-kit-local-tteeoy.laravel.cloud
LOG_CHANNEL=laravel-cloud-socket
DB_CONNECTION=mysql
SESSION_DRIVER=cookie
CACHE_STORE=databaseDB_HOST pointed at the host of the Cloud MySQL database. I'm not showing the username or password here. Cloud's environment docs explain how these variables reach your application.
One variable is missing from that list, and it caused the next problem.
Problem 2: a completely blank white page
With the build fixed and the deployment live, I opened the Cloud address and got a completely blank white page.
The cause is how my kit handles requests. It decides from the host name whether a request belongs to the central app or to a tenant. The central app lives on APP_DOMAIN, and each tenant lives on a subdomain of it. For any host it doesn't know, the kit returns 404.
APP_DOMAIN wasn't set. So the kit didn't recognize the Cloud address, and every request got that 404.
The fix was one variable. I added APP_DOMAIN with the domain only, no https://, kept APP_URL with https://, and redeployed:
APP_URL=https://saas-laravel-starter-kit-local-tteeoy.laravel.cloud
APP_DOMAIN=saas-laravel-starter-kit-local-tteeoy.laravel.cloudThe two look alike, but they do different jobs:
APP_URLis a full URL. Laravel uses it to build links. See configuration in the Laravel docs.APP_DOMAINis a bare host name. My kit puts it in the tenancy config as the central domain and checks each request's host against it.
That's why APP_DOMAIN has to be the domain only.
After the redeploy, the central app's home page loaded. It's the kit's landing page, "Run every customer workspace from one place", with Log in and Get started buttons. The central dashboard worked too, with Tenants, Users, Roles and Setup in the sidebar.


The lesson for multi-tenant apps on Cloud: set APP_DOMAIN to the Cloud address before the first deploy.
Creating a tenant
In my kit, creating a tenant runs CREATE DATABASE on the central database connection, so the database user needs that right.
From the central admin I created a tenant. Its separate database was created automatically, with no errors. The tenant's subdomain opened, and the tenant's own workspace works.
What I'd check before the first deploy
If you're putting a multi-tenant Laravel app on Laravel Cloud, these are the three things from this deploy I'd check before pushing:
- Set
APP_DOMAIN. Use the Cloud address, domain only. SetAPP_URLto the same address withhttps://. Without it, my kit served a blank page for every request. - Don't load dev-only packages in production. A service provider from a
require-devpackage breaks the build atpackage:discover. Register it only when its class exists. - Use Cloud MySQL or Serverless Postgres, not SQLite. The filesystem resets on every deploy, so a SQLite file would be lost. And an app that creates a database per tenant needs a real database server anyway.
With those three in place, the deploy came down to a few settings, a few environment variables and one database, with no server for me to manage.