Turn your content types into strongly typed models
Improve your development experience by using strongly typed models based on your Kontent.ai content types.
Life without strongly typed models
When getting content directly from the Delivery REST API, you receive content items as JSON objects. Your app then needs to parse the JSON to display your content. For example, to access the Headline element in a content item, you’d use a notation like thisresponse.data.item.elements.headline.value
.
In real-life scenarios, this approach might be cumbersome because it requires you to remember the JSON structure of your content items, and the codenames of your elements, types, languages, and other entities.
To make this easier, use a Delivery SDK (the JS versionUse strongly typed models
This practice has several advantages:- type safety during compile-time
- convenience (IntelliSense remembers content type properties for you)
- support of type-dependent functionalities
- All elements defined within a specific content type
- System fields such as type, workflow, language, and more
Generate models
Use the model generator to create strongly typed models from your Kontent.ai project by providing your environment ID.
Get strongly typed content
With your models defined and added to your application, you can use them when retrieving items from Kontent.ai.