Skip to content

Prevent duplicate

There are two ways to prevent duplicates toast. Use the one that fits your use case 👌.

Simply provide a toast id

Providing a custom toast id is certainly the most straightforward way to prevent duplicate.

<template>
  <h1>Hello {{ msg }}</h1>
</template>

<script setup lang="ts">
import { ref } from 'vue';
const msg = ref<string>('world');
</script>

Check if a toast is already displayed

Maybe there is some situations where you cannot provide a custom toast id, in that case, you can check if a toast is already displayed by calling toast.isActive(id)

<template>
  <h1>Hello {{ msg }}</h1>
</template>

<script setup lang="ts">
import { ref } from 'vue';
const msg = ref<string>('world');
</script>

Released under the MIT License.