Frequently Asked Questions

A curated summary of the top questions asked on our Slack community, often relating to implementation, functionality, and building better products generally.
Statsig FAQs
Univision OpenAI affirm Brex Microsoft ea Notion uiPath NoCap Lattice Vista Coda
GENERAL

How can I reduce the delay caused by Statsig SDK initialization in a Next.js app?

Date of slack thread: 5/7/24

Anonymous: Hi Team, we are using statsig node SDK on sever of our next js app, once the SDK is initialised we send the intialisation data via getServerSideProps to the client. On client side we are using this data to initialise the StatsigSynchronousProvider.

Everything seems to be working as expected, I just have one concern, since the rendering is completely blocked on sever while I execute Statsig.initialise(), is there any way to add a custom cutoff time to reduce the delay in main page load? Or is there any inbuilt cutoff?

Statbot: When using the Statsig Node SDK on the server side of a Next.js application, it’s important to manage the initialization time to ensure that it doesn’t excessively delay the rendering of your main page. The documentation does not explicitly mention a built-in cutoff time or a way to set a custom cutoff time for the Statsig.initialize() method. However, to mitigate potential delays, you can initialize the Statsig SDK synchronously. This approach requires a client SDK and a server SDK, and it is considered the most performant way to integrate Statsig into your website. By using a server SDK to generate the gate and experiment values for the given user, you can initialize the Statsig SDK synchronously on the client side without waiting for a network round trip to Statsig servers (source). If you’re already using StatsigSynchronousProvider on the client side with the initialization values generated by the server SDK, you are following the recommended approach for server-side rendering (SSR) to avoid delays and flicker effects (source). If you are experiencing significant delays and the documentation does not provide a solution, it may be worth exploring optimization strategies within your application’s architecture or considering asynchronous initialization patterns that do not block rendering. If the delay remains a concern, it’s advisable to profile your server-side code to identify the bottleneck and optimize accordingly.

Cooper Reid (Statsig): The initTimeoutMs initialization option will allow you to set the max time Statsig should try to initialize. After that time has elapses, the client will call back to default values defined in code for the parameter getter methods.

Cooper Reid (Statsig): You should only be calling initialize once when the web server starts, not for every incoming network request to your server. You can see here in this example that initializes called once and all subsequent calls to the SDK are evaluated locally and have a minimal amount of latency.

Anonymous: Thanks!

Statbot: This thread has been marked as resolved. Press below to re-open.

Join the #1 experimentation community

Connect with like-minded product leaders, data scientists, and engineers to share the latest in product experimentation.

Try Statsig Today

Get started for free. Add your whole team!

What builders love about us

OpenAI OpenAI
Brex Brex
Notion Notion
SoundCloud SoundCloud
Ancestry Ancestry
At OpenAI, we want to iterate as fast as possible. Statsig enables us to grow, scale, and learn efficiently. Integrating experimentation with product analytics and feature flagging has been crucial for quickly understanding and addressing our users' top priorities.
OpenAI
Dave Cummings
Engineering Manager, ChatGPT
Brex's mission is to help businesses move fast. Statsig is now helping our engineers move fast. It has been a game changer to automate the manual lift typical to running experiments and has helped product teams ship the right features to their users quickly.
Brex
Karandeep Anand
President
At Notion, we're continuously learning what our users value and want every team to run experiments to learn more. It’s also critical to maintain speed as a habit. Statsig's experimentation platform enables both this speed and learning for us.
Notion
Mengying Li
Data Science Manager
We evaluated Optimizely, LaunchDarkly, Split, and Eppo, but ultimately selected Statsig due to its comprehensive end-to-end integration. We wanted a complete solution rather than a partial one, including everything from the stats engine to data ingestion.
SoundCloud
Don Browning
SVP, Data & Platform Engineering
We only had so many analysts. Statsig provided the necessary tools to remove the bottleneck. I know that we are able to impact our key business metrics in a positive way with Statsig. We are definitely heading in the right direction with Statsig.
Ancestry
Partha Sarathi
Director of Engineering
We use cookies to ensure you get the best experience on our website.
Privacy Policy