Skip to content
On this page
Sponsor

How to use the library with Svelte?

It is quite easy to use the JS-Library in Svelte. We convert the SVG to a data URI and use it as the src.

svelte
<script>
  import { createAvatar } from "@dicebear/core";
  import { lorelei } from "@dicebear/collection";

  let avatar = createAvatar(lorelei, {
    size: 128,
    // ... other options
  }).toDataUriSync();
</script>

<img src={avatar} alt="Avatar" />