This page demonstrates how to use the Storyblok Management API to read component schemas, presets, and configuration from an external Storyblok space.
Here's how you can use these functions in your Astro pages:
---
import {
fetchExternalComponents,
fetchExternalComponent
} from '../utils/storyblok';
const SPACE_ID = import.meta.env.STORYBLOK_EXTERNAL_SPACE_ID;
// Fetch all components
const components = await fetchExternalComponents(SPACE_ID);
// Fetch a specific component
const heroComponent = await fetchExternalComponent(SPACE_ID, 'hero');
---
<div>
<h1>Components: {components.length}</h1>
{heroComponent && (
<p>Hero component has {Object.keys(heroComponent.schema).length} fields</p>
)}
</div>