statsig-wasm

Crates.iostatsig-wasm
lib.rsstatsig-wasm
version0.2.0
created_at2025-12-06 13:10:41.973553+00
updated_at2026-01-13 13:59:04.131407+00
descriptionWasm bindings for the Statsig JavaScript (Web) SDK
homepage
repository
max_upload_size
id1970145
size8,893
publish (github:dsplce-co:publish)

documentation

README

We're dsplce.co, check out our work on our website: dsplce.co ๐Ÿ–ค

statsig-wasm

๐Ÿ“ˆ Wasm bindings for the Statsig JavaScript (Web) SDK.


๐Ÿ“ฆ Installation

In your project, run:

cargo add statsig-wasm

๐Ÿ”ง Setup

Add the following script to your HTML <head> tag to make Statsig available to your Wasm module:

<script
  src="https://cdn.jsdelivr.net/npm/@statsig/js-client@3/build/statsig-js-client+session-replay+web-analytics.min.js"
  crossorigin="anonymous"
>
</script>

Bear in mind, if you're happy for Statsig to autoinitialise the client, just append ?apikey=<YOUR_CLIENT_API_KEY> to the script's src above and uninstall this crate ๐Ÿ˜‰

If you're looking to initialise the client yourself, read on.


๐Ÿงช Usage

Set a custom user ID and initialise the client:

use statsig_wasm::{StatsigClient, StatsigUser};

let statsig = StatsigClient::new(
    env!("STATSIG_API_KEY"),
    StatsigUser {
        user_id: user_id.get(),
    },
)
.unwrap();

run_statsig_auto_capture(&statsig);

// `spawn_local` is native to Leptos, use your
// framework's equivalent to run the async method.
spawn_local(async move {
    statsig.initialize().await;
});

๐Ÿ”’ License

MIT or Apache-2.0, at your option.


Commit count: 0

cargo fmt