Frontend API
Overview
The Unleash Frontend API simplifies connecting client-side applications to Unleash. Unleash Edge also implements this API allowing you to scale from development environments, low-traffic applications, or internal dashboards to a production-ready scalable solution.
The Frontend API has a straightforward setup, and since it is built directly into Unleash, you don’t need to manage it. However, unlike Unleash Edge, it cannot be scaled horizontally and isn’t designed for high request volumes.
Since the Frontend API shares the same API as Unleash Edge, you can start development with the Frontend API and transition to Unleash Edge when needed.
Configure the Frontend API
Configure cross-origin resource sharing (CORS)
For web and hybrid mobile apps, allow traffic from your application’s domains.
For Unleash, you can update CORS settings in the Unleash Admin UI in Admin settings > Access control > CORS origins. For Unleash Edge, follow our command-line for CORS settings.
Configure the API URL
Point your application to the correct API endpoint: <your-unleash-instance>/api/frontend.
Generate an API token
Your application needs a frontend token to interact with the Frontend API.
Configure the refresh interval
When a flag changes, the Frontend API picks up the change within seconds. Unleash checks for flag configuration changes every second and refreshes the flags that the Frontend API serves as soon as it finds one.
Your application gets the change the next time its frontend SDK fetches flags from the Frontend API. To control how often that happens, set the refresh interval in your SDK, for example refreshInterval in the JavaScript SDK, which defaults to 30 seconds.