Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish

# When a pull request is opened or updated the job will run the validation
# steps (using firehose, this checks for correct pubspec versioning, changelog entries, etc.).
# When you push a tag (for a package), firehose will attempt to publish that package.
on:
pull_request:
branches: [ master ]
types: [ opened, synchronize, reopened, labeled, unlabeled ]
push:
# For mono repos the tag must be prefixed with the package name,
# e.g. "inertia-dart-v1.0.0". Adjust the regular expression as needed.
tags:
- 'v*.*.*'
- '*-v*.*.*'
workflow_dispatch:

jobs:
publish:
# This job uses the common publish workflow provided by the ecosystem.
# See https://github.com/dart-lang/ecosystem/wiki/Publishing-automation
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
permissions:
id-token: write
pull-requests: write
90 changes: 74 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,84 @@
# inertia_dart

Standalone repository for the Dart implementation of the Inertia.js server-side
protocol.
Dart implementation of the [Inertia.js](https://inertiajs.com) server-side protocol. Build
single-page apps without building an API — pair any Dart HTTP server with a client adapter
like `@inertiajs/react`, `@inertiajs/vue3`, or `@inertiajs/svelte`.

This repository contains the core `inertia_dart` package and standalone
examples built around `dart:io`.
## Packages

| Package | pub.dev | Description |
| --- | --- | --- |
| [`inertia_dart`](packages/inertia) | [![pub](https://img.shields.io/pub/v/inertia_dart.svg)](https://pub.dev/packages/inertia_dart) | Core protocol — framework-agnostic props, SSR, asset helpers, and testing utilities |
| [`routed_inertia`](packages/routed_inertia) | [![pub](https://img.shields.io/pub/v/routed_inertia.svg)](https://pub.dev/packages/routed_inertia) | [Routed](https://pub.dev/packages/routed) integration — middleware, `EngineContext` helpers, config-driven setup, and SSR |
| [`serinus_inertia`](packages/serinus_inertia) | [![pub](https://img.shields.io/pub/v/serinus_inertia.svg)](https://pub.dev/packages/serinus_inertia) | [Serinus](https://pub.dev/packages/serinus) integration — `InertiaModule`, `RequestContext.inertia()`, and managed SSR |

---

### `inertia_dart` — Core Package

The framework-agnostic foundation. Use it directly with `dart:io` or as the
building block for higher-level integrations.

```dart
import 'package:inertia_dart/inertia_dart.dart';

## Workspace
final request = inertiaRequestFromHttp(httpRequest);
final page = InertiaResponseFactory().buildPageData(
component: 'Dashboard',
props: {
'user': {'name': 'Ada'},
'stats': LazyProp(() => loadStats()),
},
url: request.url,
context: request.createContext(),
version: '1.0.0',
);

```bash
dart pub get
await writeInertiaResponse(httpRequest.response, InertiaResponse.json(page));
```

## Packages
[Full docs →](https://kingwill101.github.io/docs/inertia_dart/)

---

### `serinus_inertia` — Serinus Integration

- `packages/inertia` implements the core Inertia protocol helpers for Dart.
- `packages/routed_inertia` adds Routed middleware, `EngineContext` helpers,
config wiring, and SSR support for Inertia responses.
- `packages/serinus_inertia` adds Serinus request/response adapters and
`RequestContext` helpers for Inertia responses.
Provides a first-class [Serinus](https://pub.dev/packages/serinus) experience via
`InertiaModule` and `RequestContext.inertia()`.

## Examples
```dart
import 'package:serinus/serinus.dart';
import 'package:serinus_inertia/serinus_inertia.dart';

- `examples/contacts_app` shows standalone `dart:io` usage.
- `packages/inertia/example/*` contains focused package examples.
class AppModule extends Module {
AppModule()
: super(
imports: [
InertiaModule(
options: SerinusInertiaOptions(
Comment thread
kingwill101 marked this conversation as resolved.
Resolved
version: '1.0.0',
assets: SerinusInertiaAssetOptions(
Comment thread
kingwill101 marked this conversation as resolved.
Resolved
entry: 'src/main.jsx',
clientDirectory: 'client',
includeReactRefresh: true,
),
),
),
],
controllers: [AppController()],
);
}
```

```dart
class AppController extends Controller {
AppController() : super('/') {
on(Route.get('/'), (context) async {
return context.inertia(
component: 'Home',
props: {'title': 'Hello from Serinus'},
);
});
}
}
```
5 changes: 4 additions & 1 deletion packages/inertia/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 0.1.1
## 1.0.0

- Targets Inertia.js 3.x client adapters. For Inertia.js 2.x and earlier, use
`inertia_dart` `<1.0.0`.
- Updated `artisanal` to `^0.3.0`.
- Fixed case-sensitive header lookups -- `InertiaHeaderUtils` now performs
case-insensitive matching via a new `_get()` helper, fixing compatibility
with `dart:io` `HttpHeaders` which lowercases header names.
Expand Down
8 changes: 8 additions & 0 deletions packages/inertia/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ support, and testing utilities. Pair it with a client adapter like

> **New here?** Follow the [Build a Contacts App](https://kingwill101.github.io/docs/inertia_dart/tutorial) tutorial for a hands-on walkthrough using just `dart:io`.

> **Using Serinus?** Use the [`serinus_inertia`](https://pub.dev/packages/serinus_inertia) package for a more integrated experience — it provides `InertiaModule`, `RequestContext.inertia()`, and managed SSR support out of the box.

## Install

```bash
dart pub add inertia_dart
```

| Inertia.js client version | `inertia_dart` package version |
| --- | --- |
| 3.x | `>=1.0.0` |
| `<3.0` | `<1.0.0` |

## CLI

Scaffold a Vite client with Inertia already wired:
Expand Down Expand Up @@ -248,3 +255,4 @@ response.assertInertia((page) {

- [Inertia Dart docs](https://kingwill101.github.io/docs/inertia_dart/) -- full API reference and tutorial
- [Inertia core docs](https://inertiajs.com) -- protocol specification and client adapters
- [`serinus_inertia`](https://pub.dev/packages/serinus_inertia) -- Serinus adapter with `InertiaModule`, `RequestContext.inertia()`, and managed SSR
6 changes: 3 additions & 3 deletions packages/inertia/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: inertia_dart
description: Dart implementation of Inertia.js protocol
version: 0.1.1
version: 1.0.0
repository: https://github.com/kingwill101/inertia_dart
tags:
- inertia
Expand All @@ -17,13 +17,13 @@ environment:
sdk: ">=3.9.0 <4.0.0"

dependencies:
artisanal: ^0.1.2
artisanal: ^0.3.0
http: ^1.6.0
json_annotation: ^4.9.0
meta: ^1.18.0
html: ^0.15.5
path: ^1.9.1
server_testing: ^0.3.2
server_testing: ^0.3.3
test: ^1.29.0

executables:
Expand Down
2 changes: 1 addition & 1 deletion packages/routed_inertia/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.1.1
## 1.0.0

- Eliminated code duplication -- extracted shared helpers (`inertiaRequestUrl`,
`inertiaDefaultHtml`, `consumeFlash`, `consumeErrors`,
Expand Down
8 changes: 4 additions & 4 deletions packages/routed_inertia/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: routed_inertia
description: Inertia.js integration for Routed that adds middleware, EngineContext helpers, SSR gateway wiring, and asset manifest support for hybrid apps.
version: 0.1.1
version: 1.0.0
repository: https://github.com/kingwill101/inertia_dart
tags:
- routed
Expand All @@ -11,8 +11,8 @@ environment:
sdk: ">=3.9.0 <4.0.0"

dependencies:
inertia_dart: ^0.1.1
routed: ^0.3.2
inertia_dart: ^1.0.0
routed: ^0.3.3
json_schema_builder: ^0.1.3
meta: ^1.18.0

Expand All @@ -21,5 +21,5 @@ dev_dependencies:
test: ^1.29.0
lints: ^6.0.0
routed_testing: ^0.3.2
server_testing: ^0.3.2
server_testing: ^0.3.3
file: ^7.0.1
4 changes: 2 additions & 2 deletions packages/serinus_inertia/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ environment:
sdk: ">=3.10.0 <4.0.0"

dependencies:
artisanal: ^0.1.2
inertia_dart: ^0.1.1
artisanal: ^0.3.0
inertia_dart: ^1.0.0
path: ^1.9.1
serinus: ^2.1.7

Expand Down
Loading