Sign up for early access for MySQL for Developers, a video course I'm working on.

Separate Marketing + App sites with Laravel Jetstream and Inertia.js

April 15, 2021

If you're building an application with Laravel Jetstream, you may find yourself in the situation where you want

  1. the entire app part to be owned by Intertia.js
  2. all of the marketing website as standard Blade views

I find this to be a great developer experience. All the app stuff is totally Vue + Inertia, which is great for the more complicated, interactive bits that your app will likely have, while the marketing site is plain ol' Blade. Easy to update, change, throw away, and rework.

Going down this route, there are just a few things you'll want to look out for.


It's best to set up two different Blade layouts, one for the application and one for the marketing views. This way you're not including Inertia on the pages that don't have it, and you're not including your marketing CSS and JavaScript in the Inertia part of your site.

The app layout is just the basic one from Jetstream.


<!DOCTYPE html>
<meta charset="utf-8">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>Dashboard for My Great App</title>
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<script src="{{ mix('js/app.js') }}" defer></script>
<body class="font-sans antialiased">
Code highlighting powered by (A service I created!)

And then your marketing layout can be whatever you want, but here's a basic example:


<!DOCTYPE html>
<meta charset="utf-8">
<title>Marketing for My Great App</title>
<link rel="stylesheet" href="{{ mix('css/marketing.css') }}">
<!-- Just include Alpine, no bundle needed -->
<script src="" defer></script>
<body class="font-sans antialiased">

App and Marketing on Different Domains

Even if your entire app is in a single Laravel project, it's still a good idea to separate your app and marketing domains.

This makes it easier in the future if you want to move your marketing site off to a third party application, it avoids any route collisions, and lets you scope your cookies and sessions to just the app.

You can add the domain configuration in the app.php


return [
// ...
'marketing_domain' => env('MARKETING_DOMAIN', ''),
'app_domain' => env('APP_DOMAIN', ''),

And then use the domain method to scope your routes:


Route::domain(config('app.marketing_domain'))->group(function () {
// All of your marketing routes...
Route::domain(config('app.app_domain'))->group(function () {
// All of your app routes...

The Logout Action

The last thing you'll need to customize is the LogoutResponse that Fortify sends. By default, the response is this:


class LogoutResponse implements \Laravel\Fortify\Contracts\LogoutResponse
public function toResponse($request)
return $request->wantsJson()
? new JsonResponse('', 204)
: redirect('/');

But now because we're trying to redirect to 1) another domain and 2) a non-inertia endpoint, we'll need to update this.

From the (very good) Inertia docs:

Sometimes it's necessary to redirect to an external website, or even another non-Inertia endpoint in your app, within an Inertia request. This is possible using a server-side initiated window.location visit.

That's exactly our situation!

Fortunately, Fortify makes it very easy to customize all of this stuff without having to totally eject.

We're going to create a LogoutResponse of our own and then register it.


class LogoutResponse implements \Laravel\Fortify\Contracts\LogoutResponse
public function toResponse($request)
// Use Intertia::location to redirect to an
// "external" URL, i.e. our marketing site.
return Inertia::location(route('marketing.welcome'));

Now that we have the response that we need, the last thing to do is to register it in the service container. We'll bind it to the LogoutResponseContract class.


class FortifyServiceProvider extends ServiceProvider
* Register any application services.
* @return void
public function register()
$this->app->singleton(LogoutResponseContract::class, LogoutResponse::class);

Inertia::location("That's it!")

That's all you need to do to get your Jetstream and marketing sites all set up on different domains! It's only a couple of steps, but it can be a little bit of futzing if you've never done it before. Hopefully this has made it easier.

Join my newsletter

I'll send you emails. Not too many. Anytime I post a new article, or make a new video, or do something else I think you might like. No spam, obviously.

Thanks for reading! My name is Aaron and I'm a Developer Educator at PlanetScale — a serverless MySQL database company.

My main project focus is Hammerstone, where we build components for your Laravel and Rails applications. My business partner and I do a podcast where we talk about building a software company.

I do another podcast about web frameworks called Framework Friends.

If you ever have any questions or want to chat, I'm always on Twitter
Copyright 2013 - 2023, Aaron Francis.