Inertia.js – Build React, Vue, or Svelte apps with server-side routing
inertiajs.com
inertiajs.com
However, there are also things that make it feel gimmicky:
- The resolve function createInertiaApp runs more than once (mainly) on the first page load causing a re-render and it seems like there is no plan to fix that in near feature https://github.com/inertiajs/inertia/issues/1595 / https://github.com/inertiajs/inertia/issues/1091
- There are issues like this where they could at least merge the PR to improve the documentation as there seem to be many people to misunderstand the usage the function but it did not happen https://github.com/inertiajs/inertia/issues/1631
Docs here: https://docs.adonisjs.com/guides/views-and-templates/inertia
Using inertia with SSR is very nice for the combination of:
* I want to have simple server-rendered views, with added client side sprinkling
* I want to be able to use off-the-shelf components like complex data grids to build fast
* I want to minimize API communication headaches
<%= render_react_component('MyComponent.js', :name => 'Hypernova The Renderer') %>
https://github.com/airbnb/hypernova?tab=readme-ov-file#railsThat was my only fear when I toyed with Inertia, Django, and Svelte for an afternoon. When I’d get an error it seemed obscure or not indicative of the underlying cause.
What’s everyone’s experience? Inertia seems like magic. And that’s what scares me a little.
It is just a simple bit of glue between your Vue app and your backend. The docs are good, and it overall just feels solid/stable. Super excited to see the new changes that are coming too!
The rails adapter is up to date, sponsored: https://github.com/inertiajs/inertia-rails?tab=readme-ov-fil...
By "quickly-but-gradually", I mean that some pages will remain server rendered, and gradually more migrate to being browser-rendered, but each new page or slice of functionality is very quick to port over. If you have any sort of viewmodel, presenter, or form object abstraction in your server-rendering architecture, it is much faster to just turn that into JSON and use Interia than it is to convert everything into pure JS/TS and generalize a set of APIs to serve the frontend. Of course YMMV depending on your existing architecture and needs.
The project is a lot easier to maintain and Inertia just does what it says it does.
I plan to make my next YouTube video making my case for why Laravel is better with Svelte than SvelteKit is https://youtube.com/@samldev
The whole point of it is it bridges the backend you know (Laravel, Rails, Django) with frontends (React, etc), without having to mess with JSON APIs.
The lack of a clear leader Rails clone in NodeJS land is probably the ecosystem’s biggest weakness. The downstream effect is theres a bunch of typical libraries/clients are just… MIA in the node ecosystem. Like, there’s no production grade Memcached client for node. ¯\_(ツ)_/¯ We had to fork one & heavily patch it for Notion.
Honestly, the upside of 1 language is not that high. Don't be afraid of PHP, it isn't the same language it was 15 years ago. I've been programming JS for 10 years but only been using PHP for a year, it's weird but it's got some nice parts too.
It basically gives you access to the entirety of features provided by Rails, Laravel, etc without having to write an API, create a separate codebase or deployment. You don't get any of that with SvelteKit. This is apples vs oranges.
https://youtube.com/playlist?list=PL9dIWiKCV571S3ILiADMKlZS4...
But I can't say the same with translations/localisation.
Having to load every single string from your entire application is something I don't like at all. I wish at some point we have a solution where we can just create a bundle per language so we can get code splitting, etc and just ship what's necessary for your locale.
For the Inertia project I work on at my job, we just use a "frontend" translation solution and keep the Rails translations system just for the backend.
const LOCALE_MAP: any = {
en: () =>
document.body.dataset["appEnv"] === "development"
? Promise.resolve({ default: {} as LocaleMap })
: import("@locales/admin.en.compiled.json"),
fr: () => import("@locales/admin.fr.compiled.json"),
es: () => import("@locales/admin.es.compiled.json"),
...
};
Then we consume it in a component which accepts the language key, lazy-loads the bundle by just calling `LOCALE_MAP[key]()`, and then uses it as the string translation set for a context function which looks up keys in a dict. Super simple.(Don’t tell me about having the option to manually do separate bundles like “common”, “admin”, etc… that’s just more madness)
Also why use PHP or Ruby, both as slow as JS instead of Next Nuxt or SvelteKit?
Only reason I could think is traditional shared hosting compatibility.