Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@jill64/svelte-html

jill6413.9kMITdeprecated2.0.1TypeScript support: included

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

🏷️ Declarative attribute binding for the root html element

attributes, declarative, html, svelte

readme

@jill64/svelte-html

npm-version npm-license npm-download-month npm-min-size ci.yml website

🏷️ Declarative attribute binding for the root html element

Demo

Installation

npm i @jill64/svelte-html

Usage

By passing a key-value set to the <SvelteHTML /> component, attributes are bind to the root html element.

<script>
  import { SvelteHTML } from '@jill64/svelte-html'
</script>

<SvelteHTML lang="en" prefix="example" />

<html lang="en" prefix="example">
  <!-- ... -->
</html>

SSR

Attribute binding with <SvelteHTML> is only applied on the client. To assign arbitrary attributes during SSR, use the apply function in the handle hook.

// hooks.server.js
import { apply } from '@jill64/svelte-html'

export const handle = async ({ event, resolve }) => {
  // ...
  return resolve(event, {
    transformPageChunk: apply({
      lang: 'en',
      prefix: 'example'
    })
  })
}

License

MIT