Skip to content

Custom elements documentation doesn't mention $host #16652

@owenoak

Description

@owenoak

Describe the bug

I'm converting a Svelte custom element from v4 to v5 and needed a way to get the host element in my component code.

The custom elements doc page:
https://svelte.dev/docs/svelte/custom-elements
does not mention the $host() rune -- there is a link to it in the sidebar, but there is no mention of it on that page.

A short paragraph pointing to the rune would have saved me 30-40 minutes of trolling through stack overflow/github issues trying to find out the magic incantation.

Reproduction

Logs

System Info

System:
    OS: macOS 15.6
    CPU: (12) arm64 Apple M2 Pro
    Memory: 124.95 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.18.0 - ~/.volta/tools/image/node/20.18.0/bin/node
    Yarn: 1.22.22 - ~/.volta/tools/image/yarn/1.22.22/bin/yarn
    npm: 10.8.2 - ~/.volta/tools/image/node/20.18.0/bin/npm
  Browsers:
    Chrome: 139.0.7258.129
    Safari: 18.6
  npmPackages:
    svelte: ^5.0.0 => 5.34.7

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions