Getting started
Render your first hook-backed Preact component.
import { render } from 'preact'
import { useToggle } from '@kamod-ch/hooks'
function Demo() {
const [enabled, actions] = useToggle(false)
return (
<button type="button" onClick={actions.toggle}>
{enabled ? 'Enabled' : 'Disabled'}
</button>
)
}
render(<Demo />, document.getElementById('app')!)Suggested workflow#
- browse
/hooksfor the hook you need - copy a demo that matches your use case
- check the generated type signature on the hook page
- review SSR notes for browser-only hooks before using them in static or server-rendered apps