Releases: adonisjs/inertia
Release 2.0.1
Release 1.2.3
Release 2.0.0
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
Release 1.2.2
Fix footer on splash screen
What's Changed
- fix: fixed footer of the home page by @TheoMeunier in #35
New Contributors
- @TheoMeunier made their first contribution in #35
Full Changelog: v1.2.0...v1.2.1
Use our new splash screen
What's Changed
- Add link to the Adonis Inertia starter kit repo by @marcuspoehls in #23
- Fix Inertia docs link in README.md by @marcuspoehls in #25
- change typo lucid to inertia in the readme by @nbourdin in #33
New Contributors
- @marcuspoehls made their first contribution in #23
- @nbourdin made their first contribution in #33
Full Changelog: v1.1.0...v1.2.0
Include module augmentation in config stub
Commits
- feat: include shared props module augmentation in config stub (47184ff)
Full Changelog: v1.0.0...v1.1.0
Out of experimental phase
Changes
Now that the hooks assembler and @adonisjs/vite have been stabilised, we can release @adonisjs/inertia with a stable version. No change to the API.
As a reminder, make sure you migrate to the new hooks assembler API: https://github.com/adonisjs/application/releases/tag/v8.3.1
Commits
- chore: update dependencies (61641f4)
Full Changelog: v1.0.0-29...v1.0.0
InferSharedProps and dynamic root view
Changes
InferSharedProps
One thing that was missing was the ability to have shared props automatically typesafe client side. This is now possible thanks to InferSharedProps
. To use it, you'll need to modify your config/inertia.ts
configuration file as follows :
import { defineConfig } from '@adonisjs/inertia';
import type { InferSharedProps } from '@adonisjs/inertia/types';
const inertiaConfig = defineConfig({
sharedData: {
mySharedData: 'foo'
},
});
export default inertiaConfig;
declare module '@adonisjs/inertia/types' {
export interface SharedProps extends InferSharedProps<typeof inertiaConfig> {
// If necessary, you can also manually add certain
// shared props, which would be shared from some middleware for example
manuallyAddedSharedProps: number;
}
}
Also make sure to include this reference directive in your inertia/app/app.tsx
/// <reference path="../../config/inertia.ts" />
Then, if you are already using InferPageProps
the SharedProps will be automatically added to it.
Documentation : https://docs.adonisjs.com/guides/inertia#shared-props
Dynamic root view
Sometimes you may need to define a different root view for another part of your application. Now you can, you can pass a function into the config:
import { defineConfig } from ‘@adonisjs/inertia’
export default defineConfig({
rootView: ({ request }: HttpContext) => {
if (request.url().startsWith('/admin')) {
return 'admin_layout';
}
return 'inertia_layout';
},
})
Starter kit example route
The starter-kit example route will now be available on /
, rather than /inertia
as this was a source of confusion for some users.
Commits
- refactor: add starter example route at
/
(71b8e5e) - feat: add InferSharedProps type (388553e)
- feat: dynamic root view (318d608)
- chore: update dependencies (dd6e121)
- test: fix failing test (1192c9a)
- chore: remove unused import (e4ce29d)
Full Changelog: v1.0.0-28...v1.0.0-29