{"id":15421192,"url":"https://github.com/notwoods/vite-plugin-insert-html","last_synced_at":"2026-03-03T21:02:12.333Z","repository":{"id":65696269,"uuid":"594982541","full_name":"NotWoods/vite-plugin-insert-html","owner":"NotWoods","description":"Super simple Vite plugin to insert HTML into the head or body of your HTML entrypoints.","archived":false,"fork":false,"pushed_at":"2024-12-13T06:10:18.000Z","size":29,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T23:41:36.589Z","etag":null,"topics":["html","hyperscript","inject","insert","jsx","vite","vite-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NotWoods.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":"2023-01-30T06:18:40.000Z","updated_at":"2024-12-28T20:39:41.000Z","dependencies_parsed_at":"2024-10-20T17:18:15.272Z","dependency_job_id":null,"html_url":"https://github.com/NotWoods/vite-plugin-insert-html","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"24b1810450633187739d37d1d8737e3e033141ce"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotWoods%2Fvite-plugin-insert-html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotWoods%2Fvite-plugin-insert-html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotWoods%2Fvite-plugin-insert-html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotWoods%2Fvite-plugin-insert-html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NotWoods","download_url":"https://codeload.github.com/NotWoods/vite-plugin-insert-html/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241460053,"owners_count":19966511,"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":["html","hyperscript","inject","insert","jsx","vite","vite-plugin"],"created_at":"2024-10-01T17:33:55.043Z","updated_at":"2026-03-03T21:02:12.270Z","avatar_url":"https://github.com/NotWoods.png","language":"JavaScript","readme":"# vite-plugin-insert-html [![](https://img.shields.io/npm/v/vite-plugin-insert-html.svg?style=flat)](https://www.npmjs.com/package/vite-plugin-insert-html)\n\nSuper simple Vite plugin to insert HTML into the head or body of your HTML entrypoints.\n\nAre you building a [multi-page app](https://vitejs.dev/guide/build.html#multi-page-app) where you want to include the same HTML tags in every page? Links to favicons, global CSS, social metadata, analytics scripts, any any HTML that you can think of can be easily injected to every page in your Vite app.\n\nThis plugin takes advantage of Vite's existing HTML serializer, and has no other dependencies. Simply specify the tags you want to insert, grouped by location.\n\n## Installation\n\n```bash\nnpm install --save-dev vite-plugin-insert-html\n```\n\n## Usage\n\n```js\n// vite.config.js\nimport { insertHtml, h } from 'vite-plugin-insert-html';\n\nexport default {\n  plugins: [\n    insertHtml({\n      head: [\n        h('meta', {\n          name: 'viewport',\n          content: 'width=device-width, initial-scale=1.0',\n        }),\n      ],\n      body: [h('script', { src: 'analytics.js' })],\n    }),\n  ],\n};\n```\n\n## `insertHtml`\n\n`insertHtml({ head?, headPrepend?, body?, bodyPrepend? })`\n\n### `head`, `headPrepend`, `body`, `bodyPrepend`\n\n- **Type:** `HtmlTagDescriptor[] | (context: IndexHtmlTransformContext) =\u003e HtmlTagDescriptor[]`\n- **Default:** `[]`\n\nList of tags to insert into the HTML, represented as [Vite tag descriptor objects](https://vitejs.dev/guide/api-plugin.html#transformindexhtml).\n\nTag descriptors are objects with the following properties:\n- `tag`: the HTML tag name, such as `div` or `meta`.\n- `attrs`: an object containing attribute names and string values. `true` can also be used for attributes without corresponding values.\n- `children`: an array of other tag descriptor objects. Can also be an HTML string.\n\nInstead of passing an array in directly, you can also pass in a function that lets you use a transform context while creating the tags. The transform context includes:\n- `path` that corresponds to the given HTML page, as a URL.\n- `filename` of the original HTML file.\n- `server`: a reference to the [Vite dev server](https://vitejs.dev/guide/api-javascript.html#vitedevserver) when running in development mode.\n- `bundle` and `chunk`: references to the Rollup output bundle during build mode.\n\n## `h`\n\n`h(tag, attrs, ...children)`\n\nA helper function for creating tag descriptor objects. Follows a similar format to [Preact](https://preactjs.com/guide/v10/api-reference#h--createelement) and Hyperscript.\n\n- `tag`: the HTML tag name, such as `div` or `meta`.\n- `attrs`: an object containing attribute names and string values. `true` can also be used for attributes without corresponding values.\n- `children`: other tag descriptor objects. Can also be an HTML string.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotwoods%2Fvite-plugin-insert-html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotwoods%2Fvite-plugin-insert-html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotwoods%2Fvite-plugin-insert-html/lists"}