Skip to content

Conversation

@pascalbaljet
Copy link
Member

@pascalbaljet pascalbaljet commented Oct 23, 2025

This PR brings support for settings configuration defaults, and the ability to update them during runtime. Currently, it supports three configuration settings, and this might be expanded in the future.

You can pass a default config object to the createInertiaApp() method. You don't have to pass all keys, just the ones you want to tweak.

createInertiaApp({
  // resolve, setup, etc.
  defaults: {
    form: {
      recentlySuccessfulDuration: 5_000,
    },
    prefetch: {
      cacheFor: 60_000,
    },
    visitOptions: (href: string, options: VisitOptions) => {
      return { headers: { ...options.headers, 'X-Foo': 'Bar' } }
    },
  },
})

The most interesting one here is the visitOptions callback, which acts more or less as an interceptor for Inertia requests, giving you the ability to change the options before the request is sent.

Each adapter now also exports a config instance to update the values during runtime. It supports the dot-notation.

import { config } from '@inertiajs/vue3'

config.set('form.recentlySuccessfulDuration', 1000)

You may also update multiple values at once by passing an object.

config.set({
  'form.recentlySuccessfulDuration': 1000,
  'prefetch.cacheFor': '5m',
})

Fixes #1669.

@danmatthews
Copy link

@pascalbaljet is there a way to make visitOptions here apply to router.visit() calls as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to increase recentlySuccessful time?

3 participants