crisward / svelte-tag

MIT License
52 stars 8 forks source link

How to use svelte tag custom element in none svelte app? #2

Closed BerndWessels closed 1 year ago

BerndWessels commented 3 years ago

Hi @crisward

I try to build a custom element with svelte-tag as umd library and consume it in a none svelte (vanilla js) website.

I'm confused on how to instantiate the component in the vanilla website.

Could you please explain in a few words / lines of code?

Thank you

crisward commented 3 years ago

You instantiate like any other custom element by putting your tag in the page.

So if your js is

import component from "svelte-tag"
import App from "your-app.svelte"
new component({component:App,tagname:"hello-world",attributes:["name"]})

You'd use the following in your html file.

<hello-world name="Cris"></hello-word>