diff --git a/packages/svelte5/src/lib/createInertiaApp.ts b/packages/svelte5/src/lib/createInertiaApp.ts index 5986fd871..7cec633b4 100644 --- a/packages/svelte5/src/lib/createInertiaApp.ts +++ b/packages/svelte5/src/lib/createInertiaApp.ts @@ -38,9 +38,9 @@ export default async function createInertiaApp({ const isServer = typeof window === 'undefined' const el = isServer ? null : document.getElementById(id) const initialPage: Page = page || JSON.parse(el?.dataset?.page || '{}') - const resolveComponent = (name: string) => Promise.resolve(resolve(name)) + const resolveComponent = (name: string, page: Page) => Promise.resolve(resolve(name, page)) - await resolveComponent(initialPage.component).then((initialComponent) => { + await resolveComponent(initialPage.component, initialPage).then((initialComponent) => { store.component = initialComponent as InertiaComponentType store.page = initialPage }) diff --git a/packages/svelte5/src/lib/types.d.ts b/packages/svelte5/src/lib/types.d.ts index 55374d34c..542a764c6 100644 --- a/packages/svelte5/src/lib/types.d.ts +++ b/packages/svelte5/src/lib/types.d.ts @@ -1,7 +1,7 @@ -import type { PageProps } from '@inertiajs/core' +import type { Page, PageProps } from '@inertiajs/core' import type { ComponentType } from 'svelte' -export type ComponentResolver = (name: string) => ComponentType | Promise +export type ComponentResolver = (name: string, page: Page) => ComponentType | Promise export interface InertiaComponentType extends ComponentType { default: InertiaComponentType