Skip to content

[3.x] Include SharedPageProps in createInertiaApp and event types#2956

Merged
pascalbaljet merged 7 commits into
3.xfrom
3.x-shared-page-props-types
Mar 12, 2026
Merged

[3.x] Include SharedPageProps in createInertiaApp and event types#2956
pascalbaljet merged 7 commits into
3.xfrom
3.x-shared-page-props-types

Conversation

@pascalbaljet
Copy link
Copy Markdown
Member

Backport of #2931 and #2946 to the 3.x branch.

isaackaara and others added 7 commits March 12, 2026 13:54
…types (#2931)

* fix: include SharedPageProps in createInertiaApp and onSuccess types

When users augment InertiaConfig with custom sharedPageProps, those
types were not reflected in two key places:

1. The setup function's props.initialPage in createInertiaApp - the
   generic defaulted to plain PageProps, losing the augmented types.

2. The onSuccess callback's page parameter in ClientSideVisitOptions
   used an unparameterized Page type, so page.props had no awareness
   of shared props.

This updates the default generic parameter for createInertiaApp in
all three framework adapters (Vue 3, React, Svelte) from PageProps
to PageProps & SharedPageProps. It also parameterizes the Page type
in the onSuccess callback with SharedPageProps.

Fixes #2925

* Fix code style

* Tests

* Update TypeScriptCreateInertiaApp.ts

* wip

---------

Co-authored-by: Pascal Baljet <pascal@pascalbaljet.nl>
* Use SharedPageProps in GlobalEventsMap event types

The `beforeUpdate`, `navigate`, and `success` events in `GlobalEventsMap`
use bare `Page` instead of `Page<SharedPageProps>`, which means augmented
shared props are not available when listening to these global events.

This updates those event type definitions to use `Page<SharedPageProps>`
so that users who augment `SharedPageProps` via declaration merging
get proper type inference in their event callbacks.

Fixes #2925
Fixes #2930

* Added tests

---------

Co-authored-by: Pascal Baljet <pascal@pascalbaljet.nl>
* Use SharedPageProps in GlobalEventsMap event types

The `beforeUpdate`, `navigate`, and `success` events in `GlobalEventsMap`
use bare `Page` instead of `Page<SharedPageProps>`, which means augmented
shared props are not available when listening to these global events.

This updates those event type definitions to use `Page<SharedPageProps>`
so that users who augment `SharedPageProps` via declaration merging
get proper type inference in their event callbacks.

Fixes #2925
Fixes #2930

* Added tests

---------

Co-authored-by: Pascal Baljet <pascal@pascalbaljet.nl>
@pascalbaljet pascalbaljet merged commit 3680664 into 3.x Mar 12, 2026
@pascalbaljet pascalbaljet deleted the 3.x-shared-page-props-types branch March 12, 2026 13:16
@pascalbaljet pascalbaljet added the next major release We need to consider this for the next major release, perhaps because of a breaking change label Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next major release We need to consider this for the next major release, perhaps because of a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants