npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sveltoast

v1.0.0

Published

**Sveltoast** is a super lightweight, highly optimized and customizable toast notification library built specifically for Svelte 5 and SvelteKit applications.

Readme

Sveltoast: Elegant & Modern Toasts for Svelte 5 & SvelteKit ✨

Sveltoast is a super lightweight, highly optimized and customizable toast notification library built specifically for Svelte 5 and SvelteKit applications.

🎨 Styling

Styled with Tailwind CSS v4 for easy customization.

🚀 Quick Start

Installation

npm install sveltoast

Usage

  1. Import and use in your Svelte component:
<script>
	import Sveltoast, { toast } from 'sveltoast';
</script>

<Sveltoast />

<button onclick={() => toast.success('Your changes have been saved!')}> Show Success </button>
<button onclick={() => toast.error('Failed to submit form. Please try again.')}>
	Show Error
</button>
  1. Place <Sveltoast /> once at the top level (e.g., in src/routes/+layout.svelte):
<script>
	import Sveltoast from 'sveltoast';
</script>

<Sveltoast />

📚 API Reference

toast Object

The toast object provides five methods for different notification types:

  • toast.success(message, options?)
  • toast.error(message, options?)
  • toast.info(message, options?)
  • toast.warning(message, options?)
  • toast.processing(message?, options?)

Parameters

  • message (string): The content to display. For toast.processing, you can pass null or undefined or nothing at all to show a default "Please wait a moment..." message.
  • options (object, optional): Customize the toast behavior:
    • duration (number): Auto-dismiss time in seconds. Default: 10. Set to Infinity for persistent toasts to let the user dismiss it manually.
    • position (string): Override default position for this toast.

Position Options

  • 'tr' (top-right, default)
  • 'tc' (top-center)
  • 'tl' (top-left)
  • 'br' (bottom-right)
  • 'bc' (bottom-center)
  • 'bl' (bottom-left)

<Sveltoast /> Component Props

  • duration (number, optional): Default auto-dismiss duration in seconds. Default: 10
  • position (string, optional): Default screen position. Default: 'tr'

Example: Setting Global Defaults

<script>
	import Sveltoast from 'sveltoast';
</script>

<Sveltoast duration={5} position="tc" />

💡 Advanced Usage

Handling Long-Running Operations

toast.processing is ideal for background tasks. By default, processing toasts don't auto-dismiss:

<script>
	import { toast } from 'sveltoast';

	async function submitForm() {
		toast.processing('Sending your data...');

		try {
			await new Promise((resolve) => setTimeout(resolve, 3000));
			toast.success('Form submitted successfully!');
		} catch (error) {
			toast.error('An error occurred during submission.');
		}
	}
</script>

<button onclick={submitForm}>Submit</button>

Key behavior for processing toasts:

  • Remain visible until another toast is triggered or closed by the user
  • New processing toasts replace existing ones
  • Use null/undefined message for default "Please wait..." text

Overriding Defaults Per-Toast

<script>
	import { toast } from 'sveltoast';
</script>

<button onclick={() => toast.success('2 second toast', { duration: 2 })}> Short Success </button>

<button onclick={() => toast.error('Top-left error', { position: 'tl' })}>
	Positioned Error
</button>

<button onclick={() => toast.info('Persistent info', { duration: Infinity })}>
	Persistent Info
</button>

Automatic Position Inheritance

Follow-up toasts after processing toasts inherit their position for smooth visual flow:

<script>
	import { toast } from 'sveltoast';

	async function processAndNotify() {
		toast.processing(null, { position: 'bc' });

		try {
			await new Promise((resolve) => setTimeout(resolve, 2500));
			toast.success('Completed successfully!'); // Inherits bottom-center position
		} catch (e) {
			toast.error('Operation failed!'); // Also inherits bottom-center position
		}
	}
</script>

<button onclick={processAndNotify}>Start Processing</button>

🤝 Contributing

Contributions welcome! Report bugs, suggest features to help improve Sveltoast.