« all posts

Preact with Inertia Phoenix

inertia-phoenix offers a great React installer out of box:

mix archive.install hex igniter_new
mix igniter.install inertia --client-framework=react --typescript

Here’s how to turn it into Preact:

  1. npm install preact && npm remove react-dom react

  2. tsconfig.json paths:

      "react": ["./node_modules/preact/compat/"],
      "react/jsx-runtime": ["./node_modules/preact/jsx-runtime"],
      "react-dom": ["./node_modules/preact/compat/"],
      "react-dom/*": ["./node_modules/preact/compat/*"]
  1. --alias:react=preact/compat in config.exs esbuild flags.

Note: while Inertia.js doesn’t provide a dedicated Preact client, the regular React client works well under Preact’s compatibility mode.