-
Notifications
You must be signed in to change notification settings - Fork 537
Add View Transition API Support to Inertia.js #2421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for this! I definitely want to add support for this, but I feel this PR is a little over-engineered, maybe. Why do we need the |
|
I've removed the events, what do you think? @pascalbaljet |
Thanks, much cleaner now! I think I want to remove |
|
Thanks! Please mention me again if you're done with the defaults, I can refactor this pr. |
|
Hi @pascalbaljet If there are still changes to be made, and I can still support somewhere, I would be happy to help. @Saad5400 very cool feature! Hope I can use it soon 🙂 @joetannenbaum can you support here? |
|
That's great, thank you so much! |
Add View Transition API Support to Inertia.js
Disclaimer: I was unable to comprehensively test this feature. Some help in testing would be appreciated!
Description
This pull request adds native support for the View Transition API to Inertia.js, enabling smooth animated transitions between page navigations while maintaining the framework's server-driven approach.
Problem Statement
Currently, Inertia.js provides instant page transitions but lacks support for smooth animations between pages. Developers who want animated transitions must implement custom solutions that are complex, error-prone, and don't integrate well with Inertia's visit lifecycle.
Solution
This implementation adds comprehensive View Transition API support through:
Core Changes
New Type Definitions (
packages/core/src/types.ts)ViewTransitionOptionsinterface for configurationVisittype to includeviewTransitionpropertyViewTransitionManager (
packages/core/src/viewTransition.ts)Router Integration (
packages/core/src/router.ts)setDefaultViewTransition()method for global configurationget,post,put,patch,delete,visit) to support view transition optionsResponse Integration (
packages/core/src/response.ts)Event System (
packages/core/src/events.ts)inertia:view-transition-startandinertia:view-transition-endBenefits to End Users
1. Enhanced User Experience
2. Progressive Enhancement
3. Simple API
4. Flexible Configuration
Backward Compatibility
✅ Fully backward compatible - No breaking changes to existing APIs
✅ Zero impact - Existing applications continue to work without modification
✅ Opt-in - View transitions are disabled by default
Implementation Details
Browser Support Strategy
document.startViewTransitionsupportConfiguration Options
enabled: Boolean to enable/disable transitionsupdateCallback: Custom callback during transitiononViewTransitionStart: Called when transition beginsonViewTransitionEnd: Called when transition completesonViewTransitionError: Called if transition failsUsage Patterns
Global Configuration:
Per-Visit Configuration:
Framework Integration:
CSS Styling:
Why This Doesn't Break Existing Features
How This Makes Building Web Applications Easier