{"id":13524374,"url":"https://github.com/fastify/fastify-hotwire","last_synced_at":"2025-04-05T05:09:40.283Z","repository":{"id":36980390,"uuid":"342605517","full_name":"fastify/fastify-hotwire","owner":"fastify","description":"Use the Hotwire pattern with Fastify","archived":false,"fork":false,"pushed_at":"2025-03-07T19:14:31.000Z","size":132,"stargazers_count":79,"open_issues_count":3,"forks_count":7,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-03-29T04:11:23.454Z","etag":null,"topics":["fastify","fastify-plugin","hotwire-turbo"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@fastify/hotwire","language":"JavaScript","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/fastify.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},"funding":{"github":"fastify","open_collective":"fastify"}},"created_at":"2021-02-26T14:46:43.000Z","updated_at":"2025-03-12T22:52:40.000Z","dependencies_parsed_at":"2024-01-13T22:24:49.894Z","dependency_job_id":"2f492625-6fbc-4863-b7f3-cfb43e4e4d7c","html_url":"https://github.com/fastify/fastify-hotwire","commit_stats":{"total_commits":130,"total_committers":16,"mean_commits":8.125,"dds":"0.48461538461538467","last_synced_commit":"18d31a03ec26a02799220741663f3e31323df8c2"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-hotwire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-hotwire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-hotwire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-hotwire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastify","download_url":"https://codeload.github.com/fastify/fastify-hotwire/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289429,"owners_count":20914464,"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":["fastify","fastify-plugin","hotwire-turbo"],"created_at":"2024-08-01T06:01:09.434Z","updated_at":"2025-04-05T05:09:40.263Z","avatar_url":"https://github.com/fastify.png","language":"JavaScript","readme":"# @fastify/hotwire\n\n[![CI](https://github.com/fastify/fastify-hotwire/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fastify-hotwire/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/@fastify/hotwire.svg?style=flat)](https://www.npmjs.com/package/@fastify/hotwire)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nDo you enjoy writing applications with the [hotwire](http://hotwire.dev) pattern?\nWe have got you covered!\n\nThis plugin adds all the necessary utilities to Fastify for creating a fullstack application\nwith Hotwire. Take a look at the [example](./example) folder to see it in action!\n\n## Install\n\n```\nnpm i @fastify/hotwire\n```\n\n## Usage\n\nAdd the plugin to Fastify, with at least two options:\n\n- `templates`: the location of your folder with your templates\n- `filename`: the location of your HTML generator, any templating language is supported!\n\n```js\n// in your fastify app\nfastify.register(require('@fastify/hotwire'), {\n  templates: join(__dirname, 'views'),\n  filename: join(__dirname, 'worker.js')\n})\n```\n\n```js\n// worker.js\nmodule.exports = ({ file, data, fragment }) =\u003e {\n  // your favorite templating library\n  return 'generated html'\n}\n```\n\n## API\n\n### `reply.render(filename, data)`\n\nGenerates the entire initial page, it calls the worker with `fragment: false`\n\n```js\nfastify.get('/', async (req, reply) =\u003e {\n  return reply.render('filename', { data })\n})\n```\n\n### `reply.turboGenerate.*(filename, target, data)`\n\nEvery turbo stream action is supported: `append`, `prepend`, `replace`, `update`, `remove`.\nIt generates and returns a turbo compatible fragment.\n\n```js\nfastify.get('/', async (req, reply) =\u003e {\n  const fragment = await reply.turboGenerate.append('filename', 'target', { data })\n  // send it via SSE or websockets\n})\n```\n\n### `reply.turboStream.*(filename, target, data)`\n\nEvery turbo stream action is supported: `append`, `prepend`, `replace`, `update`, `remove`.\nIt generates and send a turbo compatible fragment and configures the appropriate content type.\n\n```js\nfastify.get('/', async (req, reply) =\u003e {\n  return reply.turboStream.append('filename', 'target', { data })\n})\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","funding_links":["https://github.com/sponsors/fastify","https://opencollective.com/fastify"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-hotwire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastify%2Ffastify-hotwire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-hotwire/lists"}