This guide walks through how to add GrowthBook feature flags to an Express.js application. It assumes you are starting from scratch, so if you already have an Express.js application, you can skip to step 2.Documentation Index
Fetch the complete documentation index at: https://growthbook-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
1. Create an Express.js app
First, install Express.js- npm
- Yarn
- pnpm
- Bun
index.js file with a simple hello world route
http://localhost:3000 and you should see a “Hello World!” response!
2. Create a GrowthBook Account
GrowthBook can be self-hosted, but for simplicity, we will use GrowthBook Cloud in this guide, which is free for simple projects like this. Go to app.growthbook.io and create a new account if you don’t have one yet. Once you are logged in, create an SDK Connection and select Node.js as the language. This will generate a unique Client Key for you. Keep note of this key as we will use it in the next step.3. Integrate the GrowthBook JavaScript SDK into the Express.js app
Create the file.env if it doesn’t exist yet and add the generated key there:
- npm
- Yarn
- pnpm
- Bun
index.js file and create a GrowthBookClient instance:
index.js that creates a user-scoped instance for every request. Make sure to place this above the route handlers:
.env file, we need to modify the command to tell Node.js to load it.
4. Create a Feature in GrowthBook
Back in the GrowthBook application, we can create a new feature. For this tutorial, we’ll make a simple on/off feature flag that determines whether or not we show the message in Spanish.
index.js to use this flag:
5. Target Specific Users
Now we can add rules to the feature to turn it on for specific users. In theuserContext we added, we hard-coded an id of “123”. We can now use this id to create a rule in GrowthBook to turn on the feature for this user.
On the feature page, click the “Add Rule” button and select “Force Value” as the rule type. Then add targeting by attribute and save the rule. It should look something like this:

userContext to something else like 456, restart Node, and the response will now switch back to English.
Conclusion and Next Steps
In this tutorial, you learned how to use a simple feature flag in an Express app and target individual users. But this barely scratches the surface of what you can do with GrowthBook. Here are a few next steps you can take:- Use more advanced targeting
- Run A/B tests

