svelte-attr
v0.0.2
Published
Library that dynamically changes the attributes of html and body tags with SvelteKit's SSR
Downloads
371
Readme
svelte-attr
svelte-attr is a library that dynamically changes the attributes of html and body tags with SvelteKit's SSR.
Install
npm install svelte-attr
Usage
// src/hooks.server.ts
import type { Handle } from '@sveltejs/kit';
import { svelteAttr } from 'svelte-attr';
export const handle: Handle = async ({ event, resolve }) => {
return svelteAttr(resolve(event));
};
<script lang="ts">
import { HtmlAttr, BodyAttr } from 'svelte-attr';
</script>
<HtmlAttr lang="en" />
<BodyAttr data-theme="dark" />