Skip to main content

Domains & Subdomains

SaaSykit Tenancy allows you to use custom domain names or subdomain for your tenants' workspaces.

To achieve that all you need to do is change your Filament Panel's () configuration (app/Providers/Filament/DashboardPanelProvider.php) like the following:

class DashboardPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel->
// ... some configs of your panel
->tenantDomain('{tenant:domain}') // <- add this
->tenant(Tenant::class, 'domain'); // <- and this
}
}

The tenants table already has a domain field which will be used to store the custom domain name for each tenant.

Your job in your application is to make sure that a domain is being set for each tenant (which you could ask your tenant to pick after they purchase a subscription/an order) from you.

You might also auto-generate it based on the name of the customer for example, then allow the customer to edit it later (to avoid friction in the onboarding/checkout process).

caution

Using domains to resolve tenants adds a bit of complexity to your application, especially when users manage multiple tenants and switch between them using a dropdown in the dashboard. By default, switching domains logs the user out, requiring a new login. To prevent this and enable seamless tenant switching, you can allow wildcard session login.

To do this, update your .env file by setting SESSION_DOMAIN to .yourdomain.com, which enables session sharing across all subdomains of your domain. This will be available for subdomains though, not for custom domains.