{"id":13805294,"url":"https://github.com/devato/inertia_phoenix","last_synced_at":"2025-04-09T18:17:52.853Z","repository":{"id":48309221,"uuid":"240574799","full_name":"devato/inertia_phoenix","owner":"devato","description":"Inertiajs Adapter for Elixir Phoenix","archived":false,"fork":false,"pushed_at":"2023-09-18T10:11:03.000Z","size":218,"stargazers_count":85,"open_issues_count":4,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T18:17:47.243Z","etag":null,"topics":["elixir-phoenix","inertia-phoenix","inertiajs","inertiajs-adapter","reactjs","vuejs"],"latest_commit_sha":null,"homepage":"https://devato.com","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devato.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-02-14T18:34:14.000Z","updated_at":"2025-03-01T07:58:41.000Z","dependencies_parsed_at":"2024-01-07T10:26:41.787Z","dependency_job_id":"2f673dc7-fbaf-4d02-a3ed-e70a8d391f76","html_url":"https://github.com/devato/inertia_phoenix","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devato%2Finertia_phoenix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devato%2Finertia_phoenix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devato%2Finertia_phoenix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devato%2Finertia_phoenix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devato","download_url":"https://codeload.github.com/devato/inertia_phoenix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085328,"owners_count":21045139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir-phoenix","inertia-phoenix","inertiajs","inertiajs-adapter","reactjs","vuejs"],"created_at":"2024-08-04T01:00:59.713Z","updated_at":"2025-04-09T18:17:52.821Z","avatar_url":"https://github.com/devato.png","language":"Elixir","funding_links":[],"categories":["Adapters"],"sub_categories":["Server-side"],"readme":"# Inertia Phoenix\n\nMaintained by [Devato](https://devato.com)\n\n[![CI](https://github.com/devato/inertia_phoenix/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/devato/inertia_phoenix/actions/workflows/ci.yml)\n![Coverage](https://img.shields.io/coveralls/github/devato/inertia_phoenix/master)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2aafaf190f434aca97c9734ae2395bcc)](https://app.codacy.com/gh/devato/inertia_phoenix?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=devato/inertia_phoenix\u0026utm_campaign=Badge_Grade_Dashboard)\n[![Hex.pm](https://img.shields.io/hexpm/v/inertia_phoenix)](https://hex.pm/packages/inertia_phoenix)\n\nInertiajs Adapter for Elixir Phoenix\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Usage](#usage)\n  - [Installation](#installation)\n  - [Configuration](#configuration)\n  - [Render from Controller](#render-from-controller)\n  - [Layout/Templates](#layouttemplates)\n  - [Shared Data / Props](#shared-data--props)\n    - [Shared Data Custom Plug](#shared-data-custom-plug)\n  - [Handle Form Errors](#handle-form-errors)\n  - [Configure Axios](#configure-axios)\n- [Features](#features)\n  - [Complete](#complete)\n  - [In Progress](#in-progress)\n- [Example Apps](#example-apps)\n- [Contributing](#contributing)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n# Usage\n\nGetting started with Inertia.js in a few steps.\n\n## Installation\n\nAdd to mix.exs:\n```elixir\n{:inertia_phoenix, \"~\u003e 0.4.0\"}\n```\n\nAdd Plug to `WEB_PATH/router.ex`\n```elixir\n  pipeline :browser do\n    ...\n    plug InertiaPhoenix.Plug\n  end\n```\n\nImport render_inertia `lib/active_web.ex`\n```elixir\n  def controller do\n    quote do\n      ...\n      import InertiaPhoenix.Controller\n    end\n  end\n```\n\n## Configuration\n\nAdd to `config/config.exs`\n\n```elixir\nconfig :inertia_phoenix,\n  assets_version: 1,          # default 1\n  inertia_layout: \"app.html\"  # default app.html\n```\n\n- Asset Versioning Docs: https://inertiajs.com/asset-versioning\n\n## Render from Controller\n\nNOTE: Flash data is automatically passed through to the page props.\n\n```elixir\ndef index(conn, _params) do\n  render_inertia(conn, \"Home\", props: %{hello: \"world\"})\n\n  # OR\n\n  render_inertia(conn, \"Home\")\nend\n```\n\n## Layout/Templates\n\n- Doesn't require templates as Inertia Pages are templates.\n- `div#app` is rendered automatically.\n\nAn example layout:\n\n```eex\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    ...\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003c%= @inner_content %\u003e\n    \u003cscript type=\"text/javascript\" src=\"\u003c%= Routes.static_path(@conn, \"/js/app.js\") %\u003e\"\u003e\u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Shared Data / Props\n\nInertia.js Docs: https://inertiajs.com/shared-data\n\nTo share data:\n```elixir\nInertiaPhoenix.share(:hello, fn -\u003e :world end)\nInertiaPhoenix.share(:foo, :baz)\nInertiaPhoenix.share(\"user\", %{name: \"José\"})\n```\n\nNOTE: `props` will overwrite shared data.\n\n### Shared Data Custom Plug\n\nFor more complex data, you can create a custom plug.\n\nHere's an example from the PingCRM app:\n```elixir\ndefmodule PingWeb.Plugs.InertiaShare do\n\n  def init(default), do: default\n\n  def call(conn, _) do\n    InertiaPhoenix.share(conn, :auth, build_auth_map(conn))\n  end\n\n  defp build_auth_map(conn) do\n    # build complex auth map\n  end\nend\n```\nThen add it to any pipeline that makes sense in `myapp_web/router.ex`:\n\n```elixir\npipeline :browser do\n  ...\n  plug PingWeb.Plugs.InertiaShare # put before main Plug\n  plug InertiaPhoenix.Plug\nend\n```\n## Handle Form Errors\n\nWe can use Shared Data and the Phoenix Session to store server side errors.\n\nSee [PingCRM](https://github.com/devato/pingcrm) for examples.\n\n\n\n## Configure Axios\n\n`XSRF-TOKEN` cookie is set automatically.\n\nTo configure axios to use it by default, in `app.js`\n```javascript\nimport axios from \"axios\";\naxios.defaults.xsrfHeaderName = \"x-csrf-token\";\n```\n\n# Features\n\n## Complete\n- Render React/Vue/Svelte from controllers\n- Flash data passed to props via Plug\n- Assets Versioning: https://inertiajs.com/asset-versioning\n- Lazy Evaluation: https://inertiajs.com/responses#lazy-evaluation\n- Auto put response cookie for crsf token: https://inertiajs.com/security#csrf-protection\n- Override redirect codes: https://inertiajs.com/redirects#303-response-code\n- Partial reloads: https://inertiajs.com/requests#partial-reloads\n- Shared data interface: https://inertiajs.com/shared-data\n\n## In Progress\n\n[See Issue Tracker](https://github.com/devato/inertia_phoenix/issues)\n\n# Example Apps\n\n- N/A\n\n# Contributing\n\n[Contribution guidelines for this project](CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevato%2Finertia_phoenix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevato%2Finertia_phoenix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevato%2Finertia_phoenix/lists"}