All Projects → devato → inertia_phoenix

devato / inertia_phoenix

Licence: MIT License
Inertiajs Adapter for Elixir Phoenix

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to inertia phoenix

suomi.dev
Like Hacker News, but for Finns!
Stars: ✭ 27 (-55%)
Mutual labels:  elixir-phoenix
autoform
🤖📝 AutoForm is the simplest way to automatically generate fast, beautiful and standards/WCAG compliant HTML forms based on an Ecto Schema in a Phoenix Web Application to *significantly* speed up Web App Development. 🚀
Stars: ✭ 18 (-70%)
Mutual labels:  elixir-phoenix
RailsBooster
Pre-Configured Ruby On Rails Template To Provide Instant Productivity ⚡️
Stars: ✭ 22 (-63.33%)
Mutual labels:  inertiajs
audioslides.io
Use Amazon Polly, Google Slides and FFMpeg to create videos that can be updated at anytime by anyone. This project is written in Elixir.
Stars: ✭ 19 (-68.33%)
Mutual labels:  elixir-phoenix
phx raws
Raw websocket server on top of Phoenix.
Stars: ✭ 27 (-55%)
Mutual labels:  elixir-phoenix
inertia-go
⏩ The Inertia.js server-side adapter for Go.
Stars: ✭ 49 (-18.33%)
Mutual labels:  inertiajs
live dj
💿 Join or create video playlists to share a real-time experience with others! 🎧
Stars: ✭ 19 (-68.33%)
Mutual labels:  elixir-phoenix
pryin
PryIn is an Application Performance Monitoring platform for your Elixir/Phoenix application.
Stars: ✭ 25 (-58.33%)
Mutual labels:  elixir-phoenix
satellite
🛰️ Dashboard for probe.
Stars: ✭ 34 (-43.33%)
Mutual labels:  inertiajs
igthorn
Cryptocurrency trading platform
Stars: ✭ 86 (+43.33%)
Mutual labels:  elixir-phoenix
hippo game live
Elixir & Phoenix LiveView game
Stars: ✭ 43 (-28.33%)
Mutual labels:  elixir-phoenix
pingcrm-vite
⚡️ PingCRM on Vite Rails - A Vite.js + Inertia.js + Vue SSR + Rails demo
Stars: ✭ 48 (-20%)
Mutual labels:  inertiajs
vim-ide-elixir
Highly opininated setup of vim plugins for Elixir development
Stars: ✭ 28 (-53.33%)
Mutual labels:  elixir-phoenix
leafblower
Play Cards Against Humanity online with friends!
Stars: ✭ 29 (-51.67%)
Mutual labels:  elixir-phoenix
mindwendel
Create a challenge. Ready? Brainstorm. mindwendel helps you to easily brainstorm and upvote ideas and thoughts within your team.
Stars: ✭ 22 (-63.33%)
Mutual labels:  elixir-phoenix
page object
Page Objects for Hound / Elixir
Stars: ✭ 19 (-68.33%)
Mutual labels:  elixir-phoenix
estimator-elixir
Elixir side-project: Collaboratively estimate Jira stories (for remote teams)
Stars: ✭ 44 (-26.67%)
Mutual labels:  elixir-phoenix
revista
☂️ Reference Elixir umbrella project deployed to AWS ECS with Docker and Terraform.
Stars: ✭ 18 (-70%)
Mutual labels:  elixir-phoenix
pingcrm-yii2
Ping CRM on Yii 2 - A Yii 2 demo application to illustrate how Inertia.js works.
Stars: ✭ 39 (-35%)
Mutual labels:  inertiajs
pingcrm-mithril
Ping CRM on Mithril.js - A mithril demo application to illustrate how Inertia.js works.
Stars: ✭ 22 (-63.33%)
Mutual labels:  inertiajs

Inertia Phoenix

Maintained by Devato

Tests Coverage Codacy Badge Hex.pm

Inertiajs Adapter for Elixir Phoenix 1.4 and 1.5

Usage

Getting started with Inertia.js in a few steps.

Installation

Add to mix.exs:

{:inertia_phoenix, "~> 0.3.0"}

Add Plug to WEB_PATH/router.ex

  pipeline :browser do
    ...
    plug InertiaPhoenix.Plug
  end

Import render_inertia lib/active_web.ex

  def controller do
    quote do
      ...
      import InertiaPhoenix.Controller
    end
  end

Configuration

Add to config/config.exs

config :inertia_phoenix,
  assets_version: 1,          # default 1
  inertia_layout: "app.html"  # default app.html

Render from Controller

NOTE: Flash data is automatically passed through to the page props.

def index(conn, _params) do
  render_inertia(conn, "Home", props: %{hello: "world"})

  # OR

  render_inertia(conn, "Home")
end

Layout/Templates

  • Doesn't require templates as Inertia Pages are templates.
  • div#app is rendered automatically.

An example layout:

<!DOCTYPE html>
<html lang="en">
  <head>
    ...
  </head>
  <body>
    <%= @inner_content %>
    <script type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
  </body>
</html>

Shared Data / Props

Inertia.js Docs: https://inertiajs.com/shared-data

To share data:

InertiaPhoenix.share(:hello, fn -> :world end)
InertiaPhoenix.share(:foo, :baz)
InertiaPhoenix.share("user", %{name: "José"})

NOTE: props will overwrite shared data.

Shared Data Custom Plug

For more complex data, you can create a custom plug.

Here's an example from the PingCRM app:

defmodule PingWeb.Plugs.InertiaShare do

  def init(default), do: default

  def call(conn, _) do
    InertiaPhoenix.share(conn, :auth, build_auth_map(conn))
  end

  defp build_auth_map(conn) do
    # build complex auth map
  end
end

Then add it to any pipeline that makes sense in myapp_web/router.ex:

pipeline :browser do
  ...
  plug PingWeb.Plugs.InertiaShare # put before main Plug
  plug InertiaPhoenix.Plug
end

Handle Form Errors

We can use Shared Data and the Phoenix Session to store server side errors.

See PingCRM for examples.

Configure Axios

XSRF-TOKEN cookie is set automatically.

To configure axios to use it by default, in app.js

import axios from "axios";
axios.defaults.xsrfHeaderName = "x-csrf-token";

Features

Complete

In Progress

See Issue Tracker

Example Apps

Contributing

Contribution guidelines for this project

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].