@svelkit/hooks
v0.1.4
Published
> common hooks for [svelte] (part of [svelkit])
Downloads
44
Readme
@svelkit/hooks
What?
A hook is a function that must be called during component initialization.
Why?
Installation
npm install @svelkit/hooks
And then import it:
// using es modules
import { useAutoId } from '@svelkit/hooks'
// common.js
const { useAutoId } = require('@svelkit/hooks')
Alternatively use UNPKG or jsDelivr packages.
Hotlinking from unpkg: (no build tool needed!)
import { useAutoId } from 'https://unpkg.com/@svelkit/hooks?module'
Usage
<script>
import { useAutoId } from '@svelkit/hooks';
const autoId = useAutoId('my-form');
</script>
<label for="{autoId('name')}">Name</label>
<input id="{autoId('name')}">
<label for="{autoId('email')}">E-Mail</label>
<input id="{autoId('email')}" type="email">
License
svelkit
is open source software licensed as MIT.