https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
m

miniature-agency-3305

03/28/2023, 7:58 AM
What’s the recommended approach to trigger a refetch of feature toggles with GrowthBook? Let’s say a user logs in and I want to update the toggles based on some value that’s only available when the user is signed in. Would running setAttributes automatically trigger a refetch or do I need to retrigger creating my Growthbook instance? I saw something about autoRefresh, but that’s mainly for when features are added / updated in Growthbook I assume?
Copy code
await gb.loadFeatures({ autoRefresh: true });
Or would updating your attributes with setAttributes also retrigger an autorefresh in this scenario?
f

fresh-football-47124

03/28/2023, 8:24 AM
it triggers a refresh if you call setAttributes again
the autoRefresh is not for that - its for connecting to the GrowthBook Proxy server, otherwise it has no effect. We use Server-Sent Events, but only if you’re connecting through a GrowthBook Proxy server (https://docs.growthbook.io/self-host/proxy). - that’s what that setting controls - without that it has no effect. Alternatively, you can manually update at any time by calling
gb.refreshFeatures()
. So you can implement your own polling behavior if you want or hook into user actions like navigation or button clicks.
11 Views