{"id":50823799,"url":"https://github.com/kyuff/htmx","last_synced_at":"2026-06-13T16:35:05.431Z","repository":{"id":354956156,"uuid":"1225746134","full_name":"kyuff/htmx","owner":"kyuff","description":"Go package for building htmx-powered web applications","archived":false,"fork":false,"pushed_at":"2026-05-01T05:08:21.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-01T07:13:09.957Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/kyuff.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-30T15:39:48.000Z","updated_at":"2026-05-01T05:08:24.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kyuff/htmx","commit_stats":null,"previous_names":["kyuff/htmx"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/kyuff/htmx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyuff%2Fhtmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyuff%2Fhtmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyuff%2Fhtmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyuff%2Fhtmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyuff","download_url":"https://codeload.github.com/kyuff/htmx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyuff%2Fhtmx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34292326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-06-13T16:35:04.678Z","updated_at":"2026-06-13T16:35:05.422Z","avatar_url":"https://github.com/kyuff.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# htmx\n\n[![Build Status](https://github.com/kyuff/htmx/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/kyuff/htmx/actions/workflows/ci.yml)\n[![Report Card](https://goreportcard.com/badge/github.com/kyuff/htmx)](https://goreportcard.com/report/github.com/kyuff/htmx/)\n[![Go Reference](https://pkg.go.dev/badge/github.com/kyuff/htmx.svg)](https://pkg.go.dev/github.com/kyuff/htmx)\n[![codecov](https://codecov.io/gh/kyuff/htmx/graph/badge.svg)](https://codecov.io/gh/kyuff/htmx)\n\nA Go package for building htmx-powered web applications. It provides an HTTP handler that manages routing, template compilation, and rendering — distinguishing between full-page requests and htmx fragment requests automatically.\n\n## Installation\n\n```sh\ngo get github.com/kyuff/htmx\n```\n\nRequires Go 1.22 or later. No external dependencies.\n\n## Usage\n\n### Setup\n\n```go\nh := htmx.New()\n\n// Set the base layout template (wraps pages for full-page requests)\nh.Layout(webFS, \"layouts/base.html\")\n\n// Register global components (e.g. navbar) included in all renders\nh.AddInclude(webFS, \"partials/navbar.html\")\n\n// Serve static files\nh.FileServer(webFS, \"assets\", \"assets\")\n\nhttp.ListenAndServe(\":8080\", h)\n```\n\n### Pages and Partials\n\n```go\n// Define a typed view bound to a template file\ntype CounterVM struct{ Count int }\nvar CounterPage = htmx.NewView[CounterVM](webFS, \"counter.html\")\n\n// Register a page — renders full layout for normal requests,\n// content fragment only for htmx requests\nh.Page(\"GET /counter\", htmx.HandlerFunc(func(r *http.Request) (htmx.Response, error) {\n    return CounterPage.OK(CounterVM{Count: 0}), nil\n}))\n\n// Register a partial — always renders as an HTML fragment\nh.Partial(\"POST /counter/increment\", htmx.HandlerFunc(func(r *http.Request) (htmx.Response, error) {\n    return CounterValue.OK(CounterVM{Count: 1}), nil\n}))\n```\n\n### Response helpers\n\n```go\n// Redirect, location, stop polling, empty response\nhtmx.ClientRedirect(\"/login\")\nhtmx.ClientLocation(\"/new-page\")\nhtmx.StopPoll()\nhtmx.Empty()\n\n// Response modifiers (chainable)\nhtmx.WithTrigger(resp, \"counterUpdated\")\nhtmx.WithPushURL(resp, \"/counter\")\nhtmx.WithReswap(resp, htmx.SwapOuterHTML)\nhtmx.WithRefresh(resp)\n```\n\n### Request helpers\n\n```go\nhtmx.IsRequest(r)              // HX-Request: true\nhtmx.IsBoosted(r)              // HX-Boosted: true\nhtmx.Target(r)                 // HX-Target\nhtmx.Trigger(r)                // HX-Trigger\nhtmx.TriggerName(r)            // HX-Trigger-Name\nhtmx.CurrentURL(r)             // HX-Current-URL\nhtmx.Prompt(r)                 // HX-Prompt\n```\n\n### Testing\n\n```go\n// Render a view standalone (no layout) and assert on the HTML\nhtml := htmx.RenderTest(t, CounterPage, CounterVM{Count: 42})\n\n// Extract typed data from a Response in handler tests\nhtmx.AssertData(t, resp, func(t *testing.T, got CounterVM) {\n    assert.Equal(t, 42, got.Count)\n})\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyuff%2Fhtmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyuff%2Fhtmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyuff%2Fhtmx/lists"}