Kentico Cloud Delivery SDK
A client library for retrieving content from Kentico Cloud written in TypeScript and published in following formats: UMD
, ES2015
and CommonJs
. Works both in browser & node.
Resources |
---|
Full Documentation |
Example apps |
API Reference |
Upgrade guide |
Installation
You can install this library using npm
or you can use global CDNs such jsdelivr
directly. In both cases, you will also need to include rxjs
as its listed as peer dependency.
npm
npm i rxjs --save
npm i kentico-cloud-delivery --save
UMD Bundles
When using UMD bundle and including this library in script
tag on your html
page, you can find it under the kenticoCloudDelivery
global variable.
Bundles are distributed in _bundles
folder and there are several options that you can choose from.
- Use
kentico-cloud-delivery-sdk.browser.legacy.umd.min
if you need to support legacy browsers (IE9, IE10, IE11) - Use
kentico-cloud-delivery-sdk.browser.umd.min
if you intend to use SDK only in browsers (strips code specific to Node.js = smaller bundle) - Use
kentico-cloud-delivery-sdk.umd.min
if you need to use it in Node.js
CDN
kentico-cloud-delivery-sdk.browser.legacy.umd.min
https://cdn.jsdelivr.net/npm/kentico-cloud-delivery/_bundles/kentico-cloud-delivery-sdk.browser.legacy.umd.min.js
kentico-cloud-delivery-sdk.browser.umd.min
https://cdn.jsdelivr.net/npm/kentico-cloud-delivery/_bundles/kentico-cloud-delivery-sdk.browser.umd.min.js
kentico-cloud-delivery-sdk.umd.min
https://cdn.jsdelivr.net/npm/kentico-cloud-delivery/_bundles/kentico-cloud-delivery-sdk.umd.min.js
TypeScript & ES6
; /** * This is optional, but it is considered a best practice to define your models * so you can leverage intellisense and so that you can extend your models with * additional properties / methods. */ ; /** Getting items from Kentico Cloud as Promise */deliveryClient.items .type'movie' .toPromise .then; /** Getting items from Kentico Cloud as Observable */deliveryClient.items .type'movie' .toObservable .subscribe; /** * Get data without having custom models */deliveryClient.items .type'movie' .get .subscribe;
JavaScript & CommonJS
const KenticoCloud = ; ContentItem { super; } const deliveryClient = projectId: 'xxx' typeResolvers: 'movie' ; /** Getting items from Kentico Cloud as Promise */deliveryClient type'movie' ; /** Getting items from Kentico Cloud as Observable */const subscription = deliveryClient type'movie' ; /*Don't forget to unsubscribe from your Observables. You can use 'takeUntil' or 'unsubscribe' method for this purpose. Unsubsription is usually done when you no longer need to process the result of Observable. (Example: 'ngOnDestroy' event in Angular app)*/subscription; /** * Fetch all items of 'movie' type and given parameters from Kentico Cloud. * Important note: SDK will convert items to your type if you registered it. For example, * in this case the objects will be of 'Movie' type we defined above. * If you don't use custom models, 'ContentItem' object instances will be returned. */deliveryClient type'movie' ;
HTML & UMD
Bundles are distributed in _bundles
folder and there are several options that you can choose from.
- Use
kentico-cloud-delivery-sdk.browser.legacy.umd.min
if you need to support legacy browsers (IE9, IE10, IE11) - Use
kentico-cloud-delivery-sdk.browser.umd.min
if you intend to use SDK only in browsers (strips code specific to Node.js = smaller bundle) - Use
kentico-cloud-delivery-sdk.umd.min
if you need to use it in Node.js
Kentico Cloud SDK - Html sample See console
Testing
Note: You need to have Chrome
installed in order to run tests via Karma.
npm run test:browser
Runs tests in Chromenpm run test:node
Runs tests in node.jsnpm run test:dev
Runs developer tests (useful for testing functionality)npm run test:travis
Runs browser tests that are executed by travis
If you want to mock http responses, it is possible to use external implementation of configurable Http Service as a part of the delivery client configuration.
Feedback & Contribution
Feedback & Contributions are welcomed. Feel free to take/start an issue & submit PR.