Skip to content

Releases: adonisjs/inertia

Release 2.0.0

15 Oct 16:17
Compare
Choose a tag to compare

2.0.0 (2024-10-15)

Bug Fixes

  • handle properly null and undefined props values (e3372ac)
  • typecheck error (ee11d9b)

Support InertiaJS 2.0

13 Oct 18:02
Compare
Choose a tag to compare

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 now inertia.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

01 Oct 11:50
Compare
Choose a tag to compare

1.2.2 (2024-10-01)

Bug Fixes

  • only extract PageObject with InferPagePRops (2f2e10e), closes #36

Fix footer on splash screen

17 Sep 21:59
aaf1c0a
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.2.0...v1.2.1

Use our new splash screen

17 Sep 20:42
e45a674
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.1.0...v1.2.0

Include module augmentation in config stub

02 Jun 11:44
Compare
Choose a tag to compare

Commits

  • feat: include shared props module augmentation in config stub (47184ff)

Full Changelog: v1.0.0...v1.1.0

Out of experimental phase

02 Jun 11:31
Compare
Choose a tag to compare

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

01 Jun 22:00
Compare
Choose a tag to compare

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

v1.0.0-28

18 May 13:27
Compare
Choose a tag to compare

Commits

  • fix: usage of SSR bundle on windows (9a16acd)
  • chore: update dependencies (bb2b82a)
  • feat: add directive (6747a27)

Full Changelog: v1.0.0-27...v1.0.0-28

Update dependencies

07 May 16:24
Compare
Choose a tag to compare
  • chore: update dependencies (35bb855)

Full Changelog: v1.0.0-26...v1.0.0-27