svelte-preact-snippet
v0.1.0
Published
Create svelte snippets with JSX syntax based on preact
Downloads
2
Readme
svelte-preact-snippet
You can create svelte snippets with JSX syntax based on preact.
Usage
npm i svelte-preact-snippet preact
tsconfig.json
{
"compilerOptions": {
// ...
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}
snippet.tsx
export const snippet = createSnippet<[string, string]>((title, content) => (
<div>
<header>
<h1>{title()}</h1>
</header>
<p>{content()}</p>
<button onClick={() => alert('Clicked!\n' + content())}>Click me</button>
</div>
));
App.svelte
<script lang="ts">
import {page} from '$lib';
let name = $state('preact');
</script>
{@render page('svelte-preact-snippet', `Hello ${name}!`)}
<input type="text" bind:value={name} />
→ Demo
License
MIT