View Source ExInertia
ExInertia is a toolkit for seamlessly integrating Inertia.js with Phoenix, using Bun for JavaScript and CSS bundling.
Installation
Add ExInertia to your dependencies in mix.exs
:
def deps do
[
{:exinertia, "~> 0.1.0"}
]
end
Quick Start
ExInertia provides three main mix tasks to get you up and running:
Install ExInertia and configure your project:
mix exinertia.install
Install dependencies and Bun:
mix deps.get mix bun.install
Scaffold the Inertia frontend:
mix exinertia.setup
Configure routes (optional):
mix exinertia.setup.routes
What does exinertia.install
do?
The installer automates the basic steps for integrating ExInertia into a Phoenix project:
- Creates a Vite manifest reader in your Web app folder
- Adds Inertia and Bun to your mix.exs
- Updates config.exs to configure Bun
- Updates dev.exs watchers to point to Bun
- Modifies your router and adds an :inertia pipeline + test route
- Modifies a controller to render an Inertia page
- Creates an inertia_root.html.heex layout
- Modifies the existing root.html.heex to reference your Vite manifest
- Inserts Inertia imports into lib/myapp_web.ex
- Updates mix aliases for building/deploying assets with Bun
What does exinertia.setup
do?
The setup task:
- Clones a React TypeScript template for Inertia.js
- Sets up the frontend assets in your
assets
directory - Installs all necessary frontend dependencies using Bun
What does exinertia.setup.routes
do?
The routes setup task:
- Adds
use Routes
to your Phoenix router - Configures Routes in config/config.exs with your router module
- Sets up TypeScript definitions generation
- Optionally adds Routes.Watcher to your supervision tree for automatic route regeneration
After Installation
After running both commands, you'll need to:
- Run
mix deps.get
to install new dependencies - Run
mix bun.install
to install Bun and dependencies - Update your
tailwind.config.js
to include"./js/**/*.{js,ts,jsx,tsx}"
in the content paths
Development
Start your Phoenix server:
mix phx.server
Visit localhost:4000/inertia
to see your Inertia-powered page.
Learn More
License
ExInertia is released under the MIT License.