{"id":13805557,"url":"https://github.com/kohkimakimoto/inertia-echo","last_synced_at":"2025-03-19T12:30:35.238Z","repository":{"id":38421205,"uuid":"352534429","full_name":"kohkimakimoto/inertia-echo","owner":"kohkimakimoto","description":"The Inertia.js server-side adapter for Echo Go web framework.","archived":false,"fork":false,"pushed_at":"2024-09-29T03:14:37.000Z","size":185,"stargazers_count":12,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T07:03:36.366Z","etag":null,"topics":["go","inertia","inertiajs"],"latest_commit_sha":null,"homepage":"","language":"Go","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/kohkimakimoto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-29T06:08:47.000Z","updated_at":"2025-01-27T05:13:31.000Z","dependencies_parsed_at":"2024-01-07T10:28:05.251Z","dependency_job_id":"20073c3f-bd37-44f3-bda9-41cae0bf7ab3","html_url":"https://github.com/kohkimakimoto/inertia-echo","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kohkimakimoto%2Finertia-echo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kohkimakimoto%2Finertia-echo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kohkimakimoto%2Finertia-echo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kohkimakimoto%2Finertia-echo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kohkimakimoto","download_url":"https://codeload.github.com/kohkimakimoto/inertia-echo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244426371,"owners_count":20450951,"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":["go","inertia","inertiajs"],"created_at":"2024-08-04T01:01:02.306Z","updated_at":"2025-03-19T12:30:34.898Z","avatar_url":"https://github.com/kohkimakimoto.png","language":"Go","funding_links":[],"categories":["Go","Adapters"],"sub_categories":["Server-side"],"readme":"# inertia-echo\n\n[![test](https://github.com/kohkimakimoto/inertia-echo/actions/workflows/test.yml/badge.svg)](https://github.com/kohkimakimoto/inertia-echo/actions/workflows/test.yml)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/kohkimakimoto/inertia-echo/blob/main/LICENSE)\n[![Go Reference](https://pkg.go.dev/badge/github.com/kohkimakimoto/inertia-echo.svg)](https://pkg.go.dev/github.com/kohkimakimoto/inertia-echo)\n\nThe [Inertia.js](https://inertiajs.com) server-side adapter for [Echo](https://echo.labstack.com/) Go web framework.\n\n[Inertia.js](https://inertiajs.com) is a JavaScript library that allows you to build a fully JavaScript-based single-page app without complexity.\nI assume that you are familiar with Inertia.js and [how it works](https://inertiajs.com/how-it-works).\nYou also need to familiarize yourself with [Echo](https://echo.labstack.com/), a Go web framework. The inertia-echo assists you in developing web applications that leverage both of these technologies.\n\n## Installation\n\n```sh\ngo get github.com/kohkimakimoto/inertia-echo\n```\n\n## Minimum example\n\nPlease see [Hello World](https://github.com/kohkimakimoto/inertia-echo/tree/master/examples/helloworld) example.\n\n## Usage\n\n### Shorthand routes\n\nThe inertia-echo provides a helper function for shorthand routes like [Official Laravel Adapter](https://inertiajs.com/routing#shorthand-routes).\n\n```go\ne.GET(\"/about\", inertia.Handler(\"About\"))\n```\n\nSee also the official document: [Routing](https://inertiajs.com/routing)\n\n### Responses\n\nCreating responses.\n\n```go\nfunc ShowEventsHandler(c echo.Context) error {\n\tevent := // retrieve a event...\n\treturn inertia.Render(c, http.StatusOK, \"Event/Show\", map[string]interface{}{\n\t\t\"Event\": event,\n\t})\n}\n```\n\nRoot template data.\n\n```html\n\u003cmeta name=\"twitter:title\" content=\"{{ .page.Props.Event.Title }}\"\u003e\n```\n\nSometimes you may even want to provide data that will not be sent to your JavaScript component.\n\n```go\nfunc ShowEventsHandler(c echo.Context) error {\n\tevent := // retrieve a event...\n\treturn inertia.RenderWithViewData(c, http.StatusOK, \"Event/Show\", map[string]interface{}{\n\t\t\"Event\": event,\n\t}, map[string]interface{}{\n\t\t\"Meta\": \"Meta data...\",\n\t})\n}\n```\n\nYou can then access this variable like a regular template variable.\n\n```html\n\u003cmeta name=\"twitter:title\" content=\"{{ .Meta }}\"\u003e\n```\n\nSee also the official document: [Responses](https://inertiajs.com/responses)\n\n### Redirects\n\nYou can use Echo's standard way to redirect.\n\n```go\nreturn c.Redirect(http.StatusFound, \"/\")\n```\n\nThe following is a way to redirect to an external website in Inertia apps.\n\n```go\nreturn inertia.Location(c, \"/path/to/external\")\n```\n\nSee also the official document: [Redirects](https://inertiajs.com/redirects)\n\n### Shared data\n\nSet shared data via middleware.\n\n```go\ne.Use(inertia.MiddlewareWithConfig(inertia.MiddlewareConfig{\n\tShare: func(c echo.Context) (map[string]interface{}, error) {\n\t\tuser := // get auth user...\n\t\treturn map[string]interface{}{\n\t\t\t\"AppName\":  \"App Name\",\n\t\t\t\"AuthUser\": user,\n\t\t}, nil\n\t},\n}))\n```\n\nSet shared data manually.\n\n```go\ninertia.Share(c, map[string]interface{}{\n\t\"AppName\":  \"App Name\",\n\t\"AuthUser\": user,\n})\n```\n\nSee also the official document: [Shared data](https://inertiajs.com/shared-data)\n\n### Partial reloads\n\n```go\ninertia.Render(c, http.StatusOK, \"Index\", map[string]interface{}{\n\t// ALWAYS included on first visit\n\t// OPTIONALLY included on partial reloads\n\t// ALWAYS evaluated\n\t\"users\": users,\n\n\t// ALWAYS included on first visit...\n\t// OPTIONALLY included on partial reloads...\n\t// ONLY evaluated when needed...\n\t\"users\": func() (interface{}, error) {\n\t\tusers, err := // get users...\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn users\n\t},\n\n\t// NEVER included on first visit\n\t// OPTIONALLY included on partial reloads\n\t// ONLY evaluated when needed\n\t\"users\": inertia.Lazy(func() (interface{}, error) {\n\t\tusers, err := // get users...\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn users, nil\n\t}),\n})\n```\n\nSee also the official document: [Partial reloads](https://inertiajs.com/partial-reloads)\n\n### Asset versioning\n\nConfigure asset version via middleware.\n\n```go\ne.Use(inertia.MiddlewareWithConfig(inertia.MiddlewareConfig{\n\tVersionFunc: func() string { return version },\n}))\n```\n\nConfigure asset version manually.\n\n```go\ninertia.SetVersion(c, func() string { return version })\n```\n\nSee also the official document: [Assset versioning](https://inertiajs.com/asset-versioning)\n\n### Server-side Rendering (SSR)\n\nThe inertia-echo supports SSR. Please see [SSR Node.js](https://github.com/kohkimakimoto/inertia-echo/tree/master/examples/ssrnodejs) example.\n\nSee also the official document: [Server-side Rendering (SSR)](https://inertiajs.com/server-side-rendering)\n\n## Unsupported features\n\n### Validation\n\nThe inertia-echo does not support validation, as Echo lacks built-in validation.\nThe implementation of validation is up to you.\nIf you wish to handle validation errors with inertia-echo, you will need to implement it yourself.\n\nSee also the official document: [Validation](https://inertiajs.com/validation)\n\n## Demo application\n\n- [Hello World](https://github.com/kohkimakimoto/inertia-echo/tree/master/examples/helloworld)\n- [SSR Node.js](https://github.com/kohkimakimoto/inertia-echo/tree/master/examples/ssrnodejs)\n- [pingcrm-echo](https://github.com/kohkimakimoto/pingcrm-echo) (but it was implemented with the old version of inertia-echo)\n\n## Author\n\nKohki Makimoto \u003ckohki.makimoto@gmail.com\u003e\n\n## License\n\nThe MIT License (MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkohkimakimoto%2Finertia-echo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkohkimakimoto%2Finertia-echo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkohkimakimoto%2Finertia-echo/lists"}