Support InertiaJS 2.0
This release adds support for InertiaJS version 2.0, which is currently in pre-release: https://v2.inertiajs.com/.
@adonisjs/inertia
2.x will remain in beta while InertiaJS 2.x is in pre-release state.
Upgrade guide
First, update your frontend adapter:
npm install @inertiajs/vue3@next
// or
npm install @inertiajs/react@next
// or
npm install @inertiajs/svelte@next
Then update the AdonisJS adapter:
npm install @adonisjs/inertia@beta
Breaking changes
inertia.lazy
is nowinertia.optional
.
No other breaking changes :)
New features
All the features mentioned in the Inertia documentation are also available with the AdonisJS adapter: https://v2.inertiajs.com/upgrade-guide. Specifically:
New prop types
To use some of the features mentioned above, you will need to use specific props. The API is simple and almost identical to Laravel's. We now have inertia.merge
, inertia.defer
, inertia.always
, and inertia.optional
:
return inertia.render('MyComponent', {
mergeProp: inertia.merge(() => [1, 2, 3]),
deferProp: inertia.defer(() => 'bar'),
alwaysProp: inertia.always(() => 'always'),
deferMergeableProp: inertia.defer(() => 'bar').merge()
})
Encryption API
See https://v2.inertiajs.com/history-encryption
The encryption API is an opt-in feature. You need to enable it in your config/inertia.ts
file:
import { defineConfig } from '@adonisjs/inertia'
const inertiaConfig = defineConfig({
// ...
history: { encrypt: true },
})
Or you can also do it manually by route:
export class MyController {
index({ inertia }) {
inertia.clearHistory()
inertia.encryptHistory(true)
inertia.encryptHistory(false)
}
}
@adonisjs/inertia 2.x will remain in beta while InertiaJS is in pre-release.
Full Changelog: v1.2.2...v2.0.0-beta.0