How to Publish Inertia's Config File in Laravel

January 27th, 2025 • 2 minutes read time

Need to make a tweak to Inertia's default config? Here's how to publish the config/inertia.php config file.

As of writing this article, the official Inertia setup instructions don't mention publishing the config file for Inertia. To publish the config/inertia.php file to your own project to modify, use the vendor:publish command:

 php artisan vendor:publish

From there, select Inertia\ServiceProvider from the list. This will publish Inertia's config file.

You can also save a little time by passing in the Inertia Service Provider directly to the command:

php artisan vendor:publish --provider="Inertia\ServiceProvider"

This command works to publish assets for other packages you may have pulled in, so it's a handy one to remember for the future.

Once run, a config/inertia.php file will be published to your application. Here's what it looks like by default at the time of writing this article:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Server Side Rendering
    |--------------------------------------------------------------------------
    |
    | These options configures if and how Inertia uses Server Side Rendering
    | to pre-render the initial visits made to your application's pages.
    |
    | You can specify a custom SSR bundle path, or omit it to let Inertia
    | try and automatically detect it for you.
    |
    | Do note that enabling these options will NOT automatically make SSR work,
    | as a separate rendering service needs to be available. To learn more,
    | please visit https://inertiajs.com/server-side-rendering
    |
    */

    'ssr' => [

        'enabled' => true,

        'url' => 'http://127.0.0.1:13714',

        // 'bundle' => base_path('bootstrap/ssr/ssr.mjs'),

    ],

    /*
    |--------------------------------------------------------------------------
    | Testing
    |--------------------------------------------------------------------------
    |
    | The values described here are used to locate Inertia components on the
    | filesystem. For instance, when using `assertInertia`, the assertion
    | attempts to locate the component as a file relative to any of the
    | paths AND with any of the extensions specified here.
    |
    */

    'testing' => [

        'ensure_pages_exist' => true,

        'page_paths' => [

            resource_path('js/Pages'),

        ],

        'page_extensions' => [

            'js',
            'jsx',
            'svelte',
            'ts',
            'tsx',
            'vue',

        ],

    ],

    'history' => [

        'encrypt' => false,

    ],

];

Now you can tweak any Inertia settings, and have them reflected in your application.

If you found this article helpful, you'll love our practical screencasts.
Author
Alex Garrett-Smith
Share :

Comments

No comments, yet. Be the first!