inertia-svelte@0.7.1

Published on May 31, 2021

This release adds a new createInertiaApp() setup method to make configuring Inertia easier (#698). Here's how to use it:

Before:

import { App } from '@inertiajs/inertia-svelte'

const el = document.getElementById('app')

new App({
  target: el,
  props: {
    initialPage: JSON.parse(el.dataset.page),
    resolveComponent: name => require(`./Pages/${name}.svelte`),
  },
})

After:

import { createInertiaApp } from '@inertiajs/inertia-svelte'

createInertiaApp({
  resolve: (name) => import(`@/Pages/${name}.svelte`),
  setup({ el, App, props }) {
    new App({ target: el, props })
  },
})

By default Inertia uses app as the root element that your app will boot in. However, you can change this using the id property:

createInertiaApp({
  id: 'my-custom-div',
})