A debugging and development custom element that displays JSON data from Kontent.ai's Preview Delivery API and Management API directly within the content editing interface. Perfect for developers who need to inspect content structure, debug API responses, or understand data models during content creation.
This custom element provides an interactive JSON viewer that fetches and displays content item data from:
- Preview Delivery API - Shows how content appears through the public content delivery
- Management API - Shows the raw content item structure and metadata
- 🔄 Dual API Support - Switch between Preview Delivery and Management APIs
- 📊 Two View Modes - Schema view (expandable/collapsible) and Raw JSON view
- 📋 Copy to Clipboard - One-click copying of JSON data
- ⚡ Manual Fetching - Fetch data on-demand to avoid unnecessary API calls
The element is built with Vite and needs to be hosted securely:
- Install dependencies:
npm ci - Build for production:
npm run build - Deploy: Upload the
distfolder contents to your hosting service
Your custom element must be hosted on a secure HTTPS server. You have several options:
- Professional hosting: Use services like Netlify, Vercel, or your own server
- Local development: Use a secure tunnel like ngrok for testing
If hosting on your own server, ensure:
- Valid SSL certificate is configured
- Server sends appropriate
X-Frame-OptionsorContent-Security-Policyheaders allowinghttps://app.kontent.ai
For more details, see the Kontent.ai hosting documentation.
You'll need two API keys from your Kontent.ai project:
- Go to Project settings → API keys in your Kontent.ai project
- Find the Delivery API keys tab
- Create a Delivery API key
- Check the Content preview option
- Set the environments Limitations
- Save changes on the top right
- Go to Project settings → API keys in your Kontent.ai project
- Find the Management API keys tab
- Create or Copy a Management API key
- In Content model, open a content type for editing
- Click Custom element to add a new element
- Name the element (e.g., "API Preview")
- In Hosted code URL (HTTPS), paste your deployed element URL
- In Parameters {JSON}, add your configuration:
{
"PREVIEW_API_KEY": "your_preview_api_key_here",
"MANAGEMENT_API_KEY": "your_management_api_key_here"
}- Click Save changes
Since this is a client-side React application, please be aware of the following security considerations:
Important: API keys are stored in the custom element configuration and are accessible to anyone who can access the content type configuration in Kontent.ai. This means:
- ✅ Safe within your team: Only users with content model editing permissions can see the configuration
- ✅ Not exposed externally: The keys are not visible in your public website or to end users
⚠️ Visible to content editors: Anyone who can edit the content type can see the API keys
- Use dedicated API keys: Create specific API keys just for this custom element
- Limit permissions: Ensure the API keys have only the minimum required permissions
- Team access control: Only grant content model editing permissions to trusted team members
- Regular rotation: Consider rotating API keys periodically for enhanced security
As noted in the Kontent.ai documentation, never store sensitive data in JSON parameters if external security is a concern. For this debugging element, the risk is minimal since it's designed for internal development use within your CMS environment.
- Clone the repository
- Run
npm cito install dependencies - Run
npm run devfor local development - Use ngrok or similar to create a secure tunnel for testing in Kontent.ai
Distributed under the MIT License. See LICENSE.md for more information.