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

launchdarkly-svelte-client-sdk

v0.0.5

Published

> **⚠️ DEPRECATED: This project is no longer maintained.** > > Please migrate to the official LaunchDarkly Svelte SDK: > > - **New package**: [`@nosnibor89/svelte-client-sdk`](https://www.npmjs.com/package/@nosnibor89/svelte-client-sdk) > - **Active devel

Readme

Launch Darkly Svelte SDK

⚠️ DEPRECATED: This project is no longer maintained.

Please migrate to the official LaunchDarkly Svelte SDK:

The new package is actively maintained and includes the latest features and security updates.

This is a Svelte library for Launch Darkly. It is a wrapper around the official Launch Darkly JavaScript SDK but with a Svelte-friendly API.

Table of Contents

Getting started

First, install the package:

npm install launchdarkly-svelte-client-sdk # or use yarn or pnpm

Then, initialize the SDK with your client-side ID using the LDProvider component:

<script>
  import { LDProvider } from 'launchdarkly-svelte-client-sdk';
  import App from './App.svelte';
</script>

// Use context relevant to your application
const context = {
  user: {
    key: 'user-key',
    },
};

<LDProvider clientSideID="your-client-side-id" {context}>
  <App />
</LDProvider>

Now you can use the LDFlag component to conditionally render content based on feature flags:

<script>
	import { LDFlag } from 'launchdarkly-svelte-client-sdk';
</script>

<LDFlag flag={'my-feature-flag'}>
	<div slot="on">
		<p>this will render if the feature flag is on</p>
	</div>
	<div slot="off">
		<p>this will render if the feature flag is off</p>
	</div>
</LDFlag>

Advanced usage

Changing user context

You can change the user context by using the identify function from the LD object:

<script>
	import { LD } from 'launchdarkly-svelte-client-sdk';

    function handleLogin() {
        LD.identify({ key: 'new-user-key' });
    }
</script>

<button on:click={handleLogin}>Login</button>

Getting feature flag values

Getting immediate flag value

If you need to get the value of a flag at time of evaluation you can use the isOn function:

<script>
	import { LD } from 'launchdarkly-svelte-client-sdk';

	function handleClick() {
		const isFeatureFlagOn = LD.isOn('my-feature-flag');
		console.log(isFeatureFlagOn);
	}
</script>

<button on:click={handleClick}>Check flag value</button>

Note: Please note that isOn function will return the current value of the flag at the time of evaluation, which means you won't get notified if the flag value changes. This is useful for cases where you need to get the value of a flag at a specific time like a function call. If you need to get notified when the flag value changes, you should use the LDFlag component, the watch function or the flags object depending on you use case.

Watching flag value changes

If you need to get notified when a flag value changes you can use the watch function. The watch function is an instance of Svelte Store, which means you can use it with the $ store subscriber syntax or the subscribe method. Here is an example of how to use the watch function:

<script>
	import { LD } from 'launchdarkly-svelte-client-sdk';

	$: flagValue = LD.watch('my-feature-flag');
</script>

<p>{$flagValue}</p>

Getting all flag values

If you need to get all flag values you can use the flags object. The flags object is an instance of Svelte Store, which means you can use it with the $ store subscriber syntax or the subscribe method. Here is an example of how to use the flags object:

<script>
	import { LD } from 'launchdarkly-svelte-client-sdk';

	$: allFlags = LD.flags;
</script>

{#each Object.keys($allFlags) as flagName}
	<p>{flagName}: {$allFlags[flagName]}</p>
{/each}

Credits