Feature Flags
Platform
Product Updates

Announcing GrowthBook on JSR

Announcing GrowthBook on JSR

GrowthBook is committed to supporting modern platforms, bringing advanced feature flagging and experimentation to where you are. We’re excited to announce the availability of our JavaScript SDK on JSR, the modern open-source JavaScript registry. This integration empowers JavaScript and TypeScript developers with a seamless experience for implementing and managing feature flags in their applications.

JSR simplifies the process of publishing and importing JavaScript modules, offering robust features like TypeScript support, auto-generated documentation, and enhanced security through provenance attestation. This collaboration brings these benefits to GrowthBook users, streamlining the integration and utilization of feature flagging in their development workflows.

Using the GrowthBook JS SDK via JSR offers an excellent developer experience, with first-class TypeScript support, auto-generated documentation accessible in your code editor, and more.

How to Install GrowthBook from JSR

Get started with GrowthBook using the deno add command:

deno add jsr:@growthbook/growthbook

Or using npm:

npx jsr add @growthbook/growthbook

The above commands will generate a deno.json file, listing all project dependencies.

{
  "imports": {
    "@growthbook/growthbook": "jsr:@growthbook/growthbook@0.1.2"
  }
}


deno.json

Use GrowthBook with Express

Let’s use GrowthBook with an Express server. In our main.ts file, we can write:

import express from "express";
import { GrowthBook } from "@growthbook/growthbook";

const app = express();

app.use(function (req, res, next) {
  req.growthbook = new GrowthBook({
    apiHost: "<https://cdn.growthbook.io>",
    clientKey: "sdk-qtIKLlwNVKxdMIA5",
  });

  req.growthbook.setAttributes({
    id: req.user?.id,
  });

  res.on("close", () => req.growthbook.destroy());

  req.growthbook.init({ timeout: 1000 }).then(() => next());
});

app.get("/", (req, res) => {
  const gb = req.growthbook;

  if (gb.isOn("my-boolean-feature")) {
    res.send("Hello, boolean-feature!");
  }

  const value = gb.getFeatureValue("my-string-feature", "fallback");

  res.send(`Hello, ${value}!`);
});

console.log("Listening on port 8000");
app.listen(8000);


Finally, you can run the following command to execute:

deno -A main.ts

Depending on how you’ve set up your feature flags in GrowthBook (sign up for free), the response will be different:

Web browser showing default response, "Hello, fallback!"
Express server response showing "Hello, fallback!" when no feature flag value is configured in GrowthBook

Check out our official docs to learn more about feature flags, creating and running experiments, and analyzing experiments.

What’s next?

With GrowthBook's JS SDK now on JSR, it’s even easier to bring the power of feature flags and A/B testing to any JavaScript environment.

Table of Contents

Related Articles

See all articles
Guides
Feature Flags
Experiments
How to Migrate from Statsig to GrowthBook
Experiments
Platform
How Khan Academy Optimizes AI Tutoring with Experimentation
Feature Flags
Feature Flags: What They Are, How They Work, and Why They Matter

Ready to ship faster?

No credit card required. Start with feature flags, experimentation, and product analytics—free.