@arkstack/inertia 0.15.1 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @arkstack/inertia
2
+
3
+ [![@arkstack/inertia](https://img.shields.io/npm/dt/@arkstack/inertia?style=flat-square&label=@arkstack/inertia&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F@arkstack/inertia)](https://www.npmjs.com/package/@arkstack/inertia)
4
+
5
+ A runtime-agnostic [InertiaJS](https://inertiajs.com) server-side adapter for Arkstack. Build a single-page app (Vue, React, or Svelte) without an API: controllers return page components and props, and Inertia handles client-side routing. Works with both the Express and H3 drivers.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ pnpm add @arkstack/inertia
11
+ ```
12
+
13
+ Then register the middleware in `src/config/middleware.ts` under `before` (alongside `resora()`):
14
+
15
+ ```ts
16
+ import { inertia, resora } from '@arkstack/driver-express/middlewares' // or @arkstack/driver-h3/middlewares
17
+
18
+ export default (): MiddlewareConfig => ({
19
+ before: [resora(), inertia()],
20
+ })
21
+ ```
22
+
23
+ Publish the config and root template:
24
+
25
+ ```sh
26
+ ark publish --package @arkstack/inertia
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ```ts
32
+ import { inertia, Inertia } from '@arkstack/inertia'
33
+
34
+ // Render a page — JSON page object on Inertia visits, full HTML on first load
35
+ return inertia('Users/Index', { users: await User.all() })
36
+
37
+ // Shared props (global at boot, or request-scoped inside a handler)
38
+ inertia().share('appName', config('app.name'))
39
+
40
+ // Partial-reload helpers
41
+ inertia('Users/Index', {
42
+ users: await User.all(),
43
+ stats: Inertia.lazy(() => expensiveStats()), // only on a partial reload that asks for it
44
+ chart: Inertia.defer(() => buildChart()), // fetched by the client after load
45
+ auth: Inertia.always({ user: request.user }), // always present, even on partials
46
+ })
47
+
48
+ // Redirects (302 -> 303 for PUT/PATCH/DELETE) and external/full-page visits
49
+ Inertia.redirect('/users')
50
+ Inertia.location('https://example.com')
51
+ ```
52
+
53
+ ## Server-side rendering
54
+
55
+ Set `ssr.enabled` in `src/config/inertia.ts`, build an SSR bundle, and run it with the supervised command:
56
+
57
+ ```sh
58
+ ark inertia:ssr # runs dist-ssr/ssr.js, restarting it if it crashes
59
+ ```
60
+
61
+ The initial visit is then server-rendered and the client hydrates it; if the SSR server is unreachable the adapter falls back to client-side rendering.
62
+
63
+ ## Documentation
64
+
65
+ See the [Inertia guide](https://arkstack.toneflix.net/guide/inertia) for the full setup, partial reloads, asset versioning, configuration, and SSR.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/inertia",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "description": "InertiaJS server-side adapter for Arkstack, building the modern monolith with server-driven SPAs.",
6
6
  "homepage": "https://arkstack.toneflix.net/guide/inertia",
@@ -33,13 +33,13 @@
33
33
  "./package.json": "./package.json"
34
34
  },
35
35
  "dependencies": {
36
- "@arkstack/common": "^0.15.1"
36
+ "@arkstack/common": "^0.15.2"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@h3ravel/musket": "^2.2.1",
40
- "@arkstack/contract": "^0.15.1",
41
- "@arkstack/http": "^0.15.1",
42
- "@arkstack/view": "^0.15.1"
40
+ "@arkstack/contract": "^0.15.2",
41
+ "@arkstack/http": "^0.15.2",
42
+ "@arkstack/view": "^0.15.2"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@arkstack/view": {
@@ -1,5 +1,5 @@
1
- import type { InertiaConfig } from '@arkstack/inertia';
2
- import { env } from '@arkstack/common';
1
+ import type { InertiaConfig } from '@arkstack/inertia'
2
+ import { env } from '@arkstack/common'
3
3
 
4
4
  /**
5
5
  * Inertia adapter configuration.
@@ -36,5 +36,5 @@ export default (): InertiaConfig => {
36
36
  url: env('INERTIA_SSR_URL', 'http://127.0.0.1:13714/render'),
37
37
  bundle: 'dist-ssr/ssr.js',
38
38
  },
39
- };
40
- };
39
+ }
40
+ }