Fail the build when axios is missing (Inertia 3 compatibility)#100
Merged
shanerbaner82 merged 1 commit intomainfrom Apr 23, 2026
Merged
Fail the build when axios is missing (Inertia 3 compatibility)#100shanerbaner82 merged 1 commit intomainfrom
shanerbaner82 merged 1 commit intomainfrom
Conversation
c8c8768 to
c306a97
Compare
c306a97 to
34a5096
Compare
shanerbaner82
added a commit
to NativePHP/nativephp.com
that referenced
this pull request
Apr 23, 2026
NativePHP Mobile intercepts axios at bundle time to route HTTP requests through the embedded PHP runtime. Inertia 3 removed axios in favour of native fetch, so fresh Inertia 3 projects fail the NativePHP build until they declare axios as a direct dependency. Adds an aside to mobile/3/getting-started/development in the section that already introduces the nativephpMobile Vite plugin — that's the natural home for build-time concerns — with the single `npm install axios` step and a link to Inertia's client-side-setup docs for wiring it up. Pairs with NativePHP/mobile-air#100 which makes the Vite plugin fail early with an error pointing here and at the Inertia docs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
NativePHP Mobile intercepts `axios` at bundle time and swaps its transport adapter for one that routes requests through the embedded PHP runtime. On iOS that hits our `WKURLSchemeHandler`; on Android it hits the `WebViewClient.shouldInterceptRequest` bridge. Either way, if axios isn't installed there's nothing to intercept and outgoing HTTP requests fail to reach PHP. Through Inertia 2 this was always a given: `@inertiajs/vue3` and `@inertiajs/react` both pulled axios in as a transitive dependency, so the interception just worked. Inertia 3 removed axios in favour of native `fetch` (see https://inertiajs.com/docs/v3/installation/client-side-setup#using-axios), so fresh Inertia 3 projects build cleanly but produce an app that can't talk to its own backend. Fail fast at `config()` time with a clear error that tells users exactly what to install and links to the Inertia adapter docs. The check runs unconditionally (not only under `--mode=ios`) so users hitting the same Inertia-3-shaped failure on either platform get the same helpful nudge. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34a5096 to
23b047b
Compare
shanerbaner82
added a commit
to NativePHP/nativephp.com
that referenced
this pull request
Apr 23, 2026
…#370) NativePHP Mobile intercepts axios at bundle time to route HTTP requests through the embedded PHP runtime. Inertia 3 removed axios in favour of native fetch, so fresh Inertia 3 projects fail the NativePHP build until they declare axios as a direct dependency. Adds an aside to mobile/3/getting-started/development in the section that already introduces the nativephpMobile Vite plugin — that's the natural home for build-time concerns — with the single `npm install axios` step and a link to Inertia's client-side-setup docs for wiring it up. Pairs with NativePHP/mobile-air#100 which makes the Vite plugin fail early with an error pointing here and at the Inertia docs. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why check `package.json` and not just the filesystem
A transitive copy of axios can still sit in `node_modules` after the user removes axios from their project (e.g. `@inertiajs/core` itself depends on axios internally). A pure `existsSync` check would pass and the build would silently produce an app that can't reach PHP. Reading the project's `package.json` catches that case — the check fails unless the user has axios declared as a direct dependency of their app.
Error users will see
```
[nativephp/mobile] axios must be declared as a dependency in your package.json.
Inertia 3 removed axios in favour of native fetch; reinstall it so outgoing
requests can be routed through our handler:
npm install axios
Then follow https://inertiajs.com/docs/v3/installation/client-side-setup#using-axios
to tell Inertia to use axios for its client-side requests.
```
Backwards compatibility
Paired docs
NativePHP/nativephp.com#370 — adds an aside to `mobile/3/getting-started/development.md` covering the same Inertia 3 requirement next to the existing `nativephpMobile` Vite plugin section.
Test plan
🤖 Generated with Claude Code