import Koji from '@withkoji/core';
Exposes the Koji class, which provides client-side methods for use on the frontend of your Koji app.
Note
|
|
To use frontend methods, install the @withkoji/core package in the frontend of your project.
Import the package in your frontend code.
import Koji from '@withkoji/core';
Initialize the package with your configuration data.
// Initialize
Koji.config(require('././koji.json'));
// render
render();
Indicate that the application is ready to start receiving events.
Koji.ready();
Enable the user to upload an image from the frontend of the Koji app.
import Koji from '@withkoji/core';
const captureImage = async () => {
const imageURL = await Koji.ui.capture.image();
console.log(imageURL); // The publicly accessible, CDN-backed path of the user's uploaded image
}
Analytics, Class that enables you to track custom events in your Koji app.
Boolean, Indicates whether the package has been initialized with configuration data.
Defaults to false
.
Dispatch, Class that implements a dispatch system for real-time communication on the frontend of your Koji app.
IAP, Class that manages in-app purchase transactions on the frontend of your Koji app.
Identity, Class that manages authentication and authorization on the frontend of your Koji app.
Boolean, Indicates whether the Koji app is ready to start receiving events.
KojiMetadata, Metadata about the project and creator.
PlayerState, Class that manages the state of the Koji player to enable distinct experiences for different users and views.
String, (Optional) Unique identifier for the Koji app.
Remix, Class that manages the customization experience for your Koji app.
Services, Object that provides access to service endpoints in the Koji app. For example, you can use this property to route a request to a backend service.
const backendURL = Koji.services.backend
UI, Class that provides common user interface elements for use in your Koji app. Exposes the following classes:
Capture, Class that captures user input on the frontend of your Koji app.
Navigate, Class that provides methods for controlling navigation within your Koji app.
Present, Class that presents dialog boxes and system alerts to users on the frontend of your Koji app.
Upload, Class that uploads files from the frontend of your Koji app directly to your project’s CDN.
Initializes this package for use with configuration data from the koji.json
file.
This method sets up the services, customization values, development environment, and deployment instructions for your Koji app.
It also performs some basic structural checks.
Note
|
The app must initialize the package before any data is rendered. Initialization must be done exactly once. |
kojiConfig
– KojiConfig, (Optional) Configuration data for the Koji app.
kojiConfigOptions
– KojiConfigOptions, (Optional) Configuration options for the Koji app.
Koji.config(require('././koji.json'));
Indicates that the Koji app is ready to start receiving events.
Note
|
You must call this function after initializing the package and subscribing to customization changes but before advancing to the preview with Koji.remix.finish .
|
Koji.ready();
Configuration data for the Koji.
@@initialTransform
– Any, (Optional) Placeholder values for new customized versions.
deploy
– Any, (Optional) Instructions for deploying the services to production.
develop
– Any, (Optional) Instructions for setting up the services in a development/editor environment.
metadata
– KojiMetadata, (Optional) Metadata about the project and creator.
remixData
– Any, (Optional) Default values for the configuration data.
Configuration options for the Koji app.
metadata
– KojiMetadata, (Optional) Overrides for the platform-provided metadata.
projectId
– String, (Optional) Unique identifier for the Koji app.
services
– Services, (Optional) Defines services for the Koji app.
Metadata about the project and creator. This information is provided by the platform but can be overridden when the Koji is initialized.
projectId
– String, Unique identifier for the Koji.
creatorUsername
– String, Creator’s username.
creatorProfilePicture
– String, URL reference to the creator’s current profile picture.
Object, Key-value pairs of services and endpoints.