Skip to content

kontent-ai/custom-app-sdk-js

Repository files navigation

Kontent.ai Custom app SDK JS

Contributors Forks Stargazers Issues MIT License

Discord

About The Project

A JavaScript SDK for communicating with the Kontent.ai Custom App API. It facilitates the communication between the Kontent.ai app and the custom app providing access to the configuration and context data.

Getting Started

Installation

npm install @kontent-ai/custom-app-sdk

Important

The SDK attaches event listeners to communicate with the Kontent.ai app. Make sure to include the SDK only in the browser environment.

Usage example

import { getCustomAppContext, CustomAppContext } from "@kontent-ai/custom-app-sdk";

const response: CustomAppContext = await getCustomAppContext();

if (response.isError) {
  console.error({ errorCode: response.code, description: response.description});
} else {
  console.log({ config: response.config, context: response.context });
}

API Reference

getCustomAppContext

Use the getCustomAppContext function to retrieve the context of the custom app. The function takes no arguments and returns a promise with a value of an object of type CustomAppContext.

CustomAppContext

Property Type Description
isError boolean Determines if there was an error while getting the context of the custom app
code ErrorCode enum | null The code of the error message
description string | null The description of the error message
context object | null Contains data provided by the Kontent.ai application
config object | null Contains JSON object specified in the custom app configuration

Config

The config object is a JSON object that can be defined within the Custom App configuration under Environment settings in the Kontent.ai app.

Context

The context object contains data provided by the Kontent.ai application that you can leverage in your custom app.

Property Type Description
environmentId UUID The environment's ID
userId string The current user's ID
userEmail string The current user's email
userRoles Array of UserRole An array containing all the roles of the current user in the environment

UserRole

Property Type Description
id UUID The role's ID
codename string The role's codename - applicable only for the Project manager role

Contributing

For Contributing please see CONTRIBUTING.md for more information.

License

Distributed under the MIT License. See LICENSE.md for more information.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •