Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ssssota/svelte-preact-snippet

Create svelte snippets with JSX syntax based on preact
https://github.com/ssssota/svelte-preact-snippet

preact svelte

Last synced: 29 days ago
JSON representation

Create svelte snippets with JSX syntax based on preact

Awesome Lists containing this project

README

        

# svelte-preact-snippet

You can create svelte snippets with JSX syntax based on preact.

## Usage

```sh
npm i svelte-preact-snippet preact
```

tsconfig.json

```jsonc
{
"compilerOptions": {
// ...
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}
```

snippet.tsx

```tsx
export const snippet = createSnippet<[string, string]>((title, content) => (



{title()}



{content()}

alert('Clicked!\n' + content())}>Click me


));
```

App.svelte

```svelte

import {page} from '$lib';
let name = $state('preact');

{@render page('svelte-preact-snippet', `Hello ${name}!`)}

```

→ **[Demo](https://ssssota.github.io/svelte-preact-snippet/)**

## License

MIT