<script>
  import { copy } from 'svelte-copy';

  let { id } = $props();
  let inviteUrl = $derived(new URL(`/invite/${id}`, document.location));
  // Nota bene: we cannot use:copy={inviteUrl}, because inviteUrl is not a
  // string, and therefore will get treated as an options object. So we must
  // explicitly build an options object, containing the value that will
  // eventually be interpreted as a string.
</script>

<button use:copy={{ text: inviteUrl }}>copy</button>
<span>{inviteUrl}</span>
