0.1.4 • Published 4 years ago

@svelkit/hooks v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@svelkit/hooks

common hooks for svelte (part of svelkit)

License Latest Release View changelog Bundle Size

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.