Hi! I wanted to add Growthbook via unpkg script in...
# announcements
m
Hi! I wanted to add Growthbook via unpkg script in a SPA (Nextjs). I know I can just npm install the package but this is the requirement I currently need to work with. Trying to understand what best practice here would be 1. User navigates to a page with growthbook. Growthbook gets loaded client-side. 2. User then navigates to a page without growthbook. Since its a SPA, Growthbook variables will still be in memory. The more general question is: are there any good ways to cleanly load and unload client-side scripts for single page apps?
f
Are you able to hook into the React code at all or does it need to just be a
<script>
tag in the html template?
m
Needs to be a
<script>
tag unfortunately Is this possible?
f
It should be possible to load the SDK like that. How are you planning to use it in your app though? Do you want to do something like
growthbook.evalFeature(...)
inside a React component and have it use the globally loaded instance from the script tag?
m
Ah @future-teacher-7046 we just pushed back and were able to go with react implementation. Thanks for the time