<@U07FJ89LFFB> is there anyway to long poll growth...
# ask-ai
p
@brash-pillow-71627 is there anyway to long poll growthbook my setup is not refreshing / calling the api
o
A message from kapa.ai
Based on the information provided in the knowledge sources, there are a few options to refresh or poll for updates in GrowthBook, depending on your specific setup: 1. For JavaScript/React SDKs, you can use streaming updates with Server-Sent Events (SSE) by setting
autoRefresh: true
when calling
loadFeatures()
. This requires using the GrowthBook Proxy for self-hosted instances [GrowthBook Proxy](https://docs.growthbook.io/self-host/proxy). 2. If you're not using streaming updates, you can manually refresh features by calling
gb.refreshFeatures()
. This allows you to implement your own polling behavior or trigger updates on specific user actions [Forum Conversation](https://linen.growthbook.io/t/10118731/what-s-the-recommended-approach-to-trigger-a-refetch-of-feat). 3. For server-side implementations (e.g., Node.js), you may need to set up polyfills for EventSource to enable streaming updates:
Copy code
javascript const { setPolyfills } = require("@growthbook/growthbook"); setPolyfills({   fetch: require("cross-fetch"),   EventSource: require("eventsource"), });
[Forum Conversation](https://linen.growthbook.io/t/16601438/hi-i-am-trying-to-use-growthbook-in-nodejs-but-cannot-make-a) 4. If you're using the Java SDK, you can use the
GBFeaturesRepository
class to manage feature refreshing. You can configure the TTL (Time To Live) for cached features [Forum Conversation](https://linen.growthbook.io/t/10113860/hi-i-am-exploring-growthbook-java-sdk-i-have-a-very-basic-qu). 5. For other SDKs that don't support streaming updates, you might need to implement your own polling mechanism by periodically calling
loadFeatures()
or a similar method depending on the SDK you're using. If none of these options work for your specific setup, you may need to provide more details about your implementation to get more targeted advice.
p
im using react-native
@brash-pillow-71627 im using react native
o
A message from kapa.ai
For React Native, GrowthBook offers support for streaming updates, but it requires some additional setup due to React Native's limitations. Here's how you can implement it: 1. First, you need to install a polyfill for Server-Sent Events (SSE). GrowthBook recommends using the
react-native-sse
library:
Copy code
bash npm install --save react-native-sse
2. Then, you need to configure GrowthBook to use this polyfill:
Copy code
javascript import { setPolyfills } from "@growthbook/growthbook"; import EventSource from "react-native-sse";  // Configure GrowthBook to use the eventsource library setPolyfills({   EventSource: EventSource });
3. After setting up the polyfill, you can enable streaming updates by passing
streaming: true
when initializing GrowthBook:
Copy code
javascript gb.init({   streaming: true,   // Other options... })
This setup should allow your React Native app to receive real-time updates from GrowthBook without the need for manual polling. If you're still experiencing issues with refreshing or calling the API, you can manually refresh features by calling
gb.refreshFeatures()
at specific points in your app lifecycle or on user actions. For more details, you can refer to the [React Native Streaming Updates documentation](https://docs.growthbook.io/lib/react-native#streaming-updates). Remember that streaming updates are only supported on GrowthBook Cloud or if you're running a GrowthBook Proxy Server. If you're self-hosting GrowthBook, make sure you have the proxy set up correctly.