diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 5bb2b747..1ca2cee5 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -115,6 +115,7 @@ export default defineConfig({ { text: 'Forms', link: '/guide/forms' }, { text: 'File uploads', link: '/guide/file-uploads' }, { text: 'Validation', link: '/guide/validation' }, + { text: 'View transitions', link: '/guide/view-transitions' }, ], }, { diff --git a/docs/guide/client-side-setup.md b/docs/guide/client-side-setup.md index 9029720d..01732666 100644 --- a/docs/guide/client-side-setup.md +++ b/docs/guide/client-side-setup.md @@ -114,6 +114,102 @@ createInertiaApp({ The `setup` callback receives everything necessary to initialize the client-side framework, including the root Inertia `App` component. +## Configuring defaults + +@available_since core=2.2.11 + +You may pass a `defaults` object to `createInertiaApp()` to configure default settings for various features. You don't have to pass all keys, just the ones you want to tweak. + +```js +createInertiaApp({ + // ... + defaults: { + form: { + recentlySuccessfulDuration: 5000, + }, + prefetch: { + cacheFor: '1m', + hoverDelay: 150, + }, + visitOptions: (href, options) => { + return { + headers: { + ...options.headers, + 'X-Custom-Header': 'value', + }, + } + }, + }, +}) +``` + +The `visitOptions` callback receives the target URL and the current visit options, and should return an object with any options you want to override. For more details on the available configuration options, see the [forms](/guide/forms#form-errors), [prefetching](/guide/prefetching), and [manual visits](/guide/manual-visits#global-visit-options) documentation. + +### Updating at runtime + +You may also update configuration values at runtime using the exported `config` instance. This is +particularly useful when you need to adjust settings based on user preferences or application state. + +:::tabs key:frameworks +== Vue + +```js +import { router } from '@inertiajs/vue3' + +// Set a single value using dot notation... +config.set('form.recentlySuccessfulDuration', 1000) +config.set('prefetch.cacheFor', '5m') + +// Set multiple values at once... +config.set({ + 'form.recentlySuccessfulDuration': 1000, + 'prefetch.cacheFor': '5m', +}) + +// Get a configuration value... +const duration = config.get('form.recentlySuccessfulDuration') +``` + +== React + +```js +import { router } from '@inertiajs/react' + +// Set a single value using dot notation... +config.set('form.recentlySuccessfulDuration', 1000) +config.set('prefetch.cacheFor', '5m') + +// Set multiple values at once... +config.set({ + 'form.recentlySuccessfulDuration': 1000, + 'prefetch.cacheFor': '5m', +}) + +// Get a configuration value... +const duration = config.get('form.recentlySuccessfulDuration') +``` + +== Svelte 4|Svelte 5 + +```js +import { router } from '@inertiajs/svelte' + +// Set a single value using dot notation... +config.set('form.recentlySuccessfulDuration', 1000) +config.set('prefetch.cacheFor', '5m') + +// Set multiple values at once... +config.set({ + 'form.recentlySuccessfulDuration': 1000, + 'prefetch.cacheFor': '5m', +}) + +// Get a configuration value... +const duration = config.get('form.recentlySuccessfulDuration') +``` + +::: + # Resolving components The `resolve` callback tells Inertia how to load a page component. It receives a page name (string), and returns a page component module. How you implement this callback depends on which bundler (Vite or Webpack) you're using. diff --git a/docs/guide/error-handling.md b/docs/guide/error-handling.md index c808c214..5acca89d 100644 --- a/docs/guide/error-handling.md +++ b/docs/guide/error-handling.md @@ -6,6 +6,25 @@ One of the advantages to working with a robust server-side framework is the buil Inertia solves this issue by showing all non-Inertia responses in a modal. This means you get the same beautiful error-reporting you're accustomed to, even though you've made that request over XHR. +## Dialog element + +@available_since core=2.2.13 + +By default, Inertia displays error modals using a custom `
` overlay. However, you can opt-in to using the native HTML `` element instead, which provides built-in modal functionality including backdrop handling. + +To enable this, configure the `future.useDialogForErrorModal` option in your [application defaults](/guide/client-side-setup#configuring-defaults). + +```js +createInertiaApp({ + // resolve, setup, etc. + defaults: { + future: { + useDialogForErrorModal: true, + }, + }, +}) +``` + ## Production In production you will want to return a proper Inertia error response instead of relying on the modal-driven error reporting that is present during development. To accomplish this, you'll need to update your framework's default exception handler to return a custom error page. diff --git a/docs/guide/forms.md b/docs/guide/forms.md index 3378abc5..55ece8e3 100644 --- a/docs/guide/forms.md +++ b/docs/guide/forms.md @@ -151,7 +151,7 @@ You can pass a `transform` prop to modify the form data before submission. This ### Default values -You can set default values for form inputs using standard HTML attributes. Use `defaultValue``value``value``defaultValue` (`value` for Svelte < `5.6.0`) for text inputs and textareas, and `defaultChecked``checked``checked``defaultChecked` (`checked` for Svelte < `5.6.0`) for checkboxes and radios. +You can set default values for form inputs using standard HTML attributes. Use `defaultValue``defaultValue``value``defaultValue` (`value` for Svelte < `5.6.0`) for text inputs and textareas, and `defaultChecked``defaultChecked``checked``defaultChecked` (`checked` for Svelte < `5.6.0`) for checkboxes and radios. :::tabs key:frameworks @@ -160,7 +160,7 @@ You can set default values for form inputs using standard HTML attributes. Use < ```vue