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

svelte-bay

v0.1.2

Published

The simplest, most developer-friendly portal system for Svelte 5. Teleport content anywhere in your app with zero config using Svelte 5 Runes.

Downloads

28

Readme

🏝️ Svelte Bay

The simplest, most developer-friendly portal system for Svelte 5.

svelte-bay allows you to easily teleport content from anywhere in your app to specific "bays" (portals) in your layout using the power of Svelte 5 Runes and Context.

✨ Features

  • 🚀 Zero Config: Just initialize and go.
  • ⚡️ Svelte 5 Ready: Built with Runes ($state, $effect) for maximum performance.
  • 🛡️ SSR Safe: Uses setContext to ensure state is scoped to the current request tree.
  • 📦 Multi-Pod Support: Stack multiple pods into a single portal bay.

📦 Installation

npm install svelte-bay
# or
bun add svelte-bay

⚡️ Quick Start with CLI

The easiest way to get started - one command does it all:

# Run this in your SvelteKit project directory
npx svelte-bay init

The CLI will:

  • ✅ Automatically install svelte-bay (asks which package manager to use)
  • ✅ Find your root +layout.svelte (or create it if missing)
  • ✅ Add the createBay() import and call
  • ✅ Optionally add the Vite plugin for type safety (autocomplete Portal names)
  • ✅ Handle all edge cases intelligently

That's it! You're ready to use <Portal> and <Pod> components.

🛠️ Usage

1. Initialize the Bay System

💡 Tip: You can skip this step by running npx svelte-bay init

In your root layout (usually src/routes/+layout.svelte), initialize the system. This sets up the context for your app.

<script lang="ts">
  import { createBay } from 'svelte-bay';

  // Initialize the bay system once at the root
  createBay();

  let { children } = $props();
</script>

{@render children()}

2. Create a Portal (The Destination)

Place a <Portal /> wherever you want content to appear. Give it a unique name.

<script>
  import { Portal } from 'svelte-bay';
</script>

<header class="flex justify-between p-4">
  <h1>My App</h1>

  <!-- Content sent to 'header-actions' will appear here -->
  <div class="actions">
    <Portal name="header-actions" />
  </div>
</header>

3. Send Content via a Pod (The Source)

From any component in your app, use a <Pod /> to teleport content to a portal.

<script>
  import { Pod } from 'svelte-bay';
</script>

<Pod to="header-actions">
  <button class="btn-primary">Save Changes</button>
</Pod>

<Pod to="header-actions">
  <button class="btn-secondary">Cancel</button>
</Pod>

💡 How it Works

  1. createBay(): Creates a reactive $state registry and shares it via setContext.
  2. <Pod />: Registers its children snippet to the registry key matching its to prop.
  3. <Portal />: Listens to the registry and renders all snippets registered to its name.

🛡️ Type Safety (Optional)

By default, svelte-bay works with any string for portal names. If you want full type safety and autocomplete, you can use our Vite plugin.

Automatic Type Generation ⚡️

  1. Add the plugin to your vite.config.ts:
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vite";
import { svelteBay } from "svelte-bay/vite";

export default defineConfig({
  plugins: [sveltekit(), svelteBay()],
});
  1. Run your dev server (npm run dev).
  2. A src/svelte-bay.d.ts file will be generated automatically.
  3. Now <Pod to="..."> and <Portal name="..."> will autocomplete with your portal names!

Manual Registry 🛠️

If you prefer not to use the plugin, you can manually define your portal names in your src/app.d.ts:

// src/app.d.ts
import "svelte-bay";

declare module "svelte-bay" {
  interface PortalRegistry {
    header: boolean;
    sidebar: boolean;
  }
}

📄 License

MIT