Provide access from your web app to your CloudKit app’s containers and databases.
- CloudKit JS 1.0+
Use CloudKit JS to build a web interface that lets users access the same public and private databases as your CloudKit app running on iOS or macOS. You must have an existing CloudKit app and enable web services to use CloudKit JS.
Before You Begin
Set up your app’s containers and configure CloudKit JS.
Create your app’s containers and schema.
If you are new to CloudKit, start by reading CloudKit Quick Start. You’ll use Xcode to create your app’s containers and use CloudKit Dashboard to view the containers. Then create an iOS or Mac app that uses CloudKit to store your app’s data.
In CloudKit Dashboard, enable web services by creating either an API token or server-to-server key.
Use an API Token from a website or an embedded web view in a native app, or when you need to authenticate the user. To create an API token, read Accessing CloudKit Using an API Token in CloudKit Web Services Reference.
Embed CloudKit JS in your webpage.
Embed CloudKit JS in your webpage using the
scripttag and link to Apple’s hosted version of CloudKit JS at
.apple-cloudkit .com/ck/2/cloudkit .js
To enable strict mode for an entire script, put "use strict" before any other statements.
Configure CloudKit JS.
configuremethod to provide information about your app’s containers to CloudKit JS. Also, specify whether to use the development or production environment. See
Cloudfor an example, and see CloudKit JS Data Types for details on the
Cloudproperties you can set.
Kit .Cloud Kit Config
The following resources provide more information about CloudKit:
CloudKit Quick Start gets you started creating a CloudKit native app.
CloudKit teaches you how to write native app code.
CloudKit Web Services Reference describes the HTTP interface to CloudKit containers and databases.
iCloud Design Guide provides an overview of all the iCloud services available to apps submitted to the App Store or Mac App Store.