Quick start (manual)
This guide describes how to start developing for the Sitecore Marketplace locally by connecting a JavaScript or TypeScript app to Sitecore using the Marketplace SDK. This guide is for building a client-side app with built-in authorization.
In this guide, you:
Prerequisites
Check that you have the following before getting started:
-
A Marketplace app installed in your Sitecore Cloud Portal organization.
-
Node.js 16 or later. Check your installed version by using the
node --versioncommand. -
npm 10 or later. Check your installed version by using the
npm --versioncommand.NoteWe strongly recommend that you also install Blok in your app. Blok is the Sitecore product design system, and installing it is the easiest way you can give your app the Sitecore look and feel.
Matching the Sitecore look and feel is required for public Marketplace apps and strongly recommended for custom Marketplace apps. This is to ensure a consistent user experience for the Sitecore product user.
Create an app
If you don't already have an app, create a JavaScript or TypeScript one.
To create a new JavaScript or TypeScript app, run the following command in your terminal:
To create a new JavaScript or TypeScript app, run the following command in your terminal:
When prompted, select:
- Yes for TypeScript and the
src/directory. - No for App Router and customizing the import alias.
- Yes or No for the other prompts, depending on your application requirements.
To create a new JavaScript or TypeScript app, run the following command in your terminal:
When prompted, select:
- Yes for TypeScript, the
src/directory, and App Router. - No for customizing the import alias.
- Yes or No for the other prompts, depending on your application requirements.
Install the packages
To install the Marketplace SDK packages in your app, run the following commands:
Initialize the SDK
To initialize the Marketplace SDK:
-
In your code editor, in the
srcfolder of your app, create a hook, for example,/utils/hooks/useMarketplaceClient.ts. -
Paste the following code into your new hook:
React and Next.jsThis script manages the initialization and state of the SDK and sets up communication with
window.parentso the app can run in an iframe. -
In your app's main page, such as
App.tsxorpages/index.tsx, initialize the Marketplace client in an Effect Hook and create your first query:ReactNext.js (Pages Router)Next.js (App Router)This script:
- Uses an Effect Hook to check if the Marketplace client is initialized.
- Makes a query to retrieve details about your Marketplace app:
client.query("application.context") - Extracts the app details from the API response and stores it in state:
setAppContext(res.data); - Displays the app name in the user interface:
<h1>Welcome to {appContext?.name}</h1>
-
Start your app by entering the following command in your terminal:
NoteStart your app on the same localhost address that you specified during app configuration.
Open your app in Sitecore
After initializing the SDK, you open your Marketplace app in a Sitecore extension point you selected for it during app configuration.
To open your app in Sitecore:
-
In your web browser, in the Cloud Portal, find and open your Marketplace app in one of its extension points.
Your app now appears in Sitecore and the two are securely communicating.
-
On the same page, open your console to find the logs included in the SDK initialization code.
NoteDuring development, trace console logs in your web browser's console in the Sitecore extension point, not on your app's localhost address.
Similarly, always preview your app in the Sitecore extension point. Any functionality that requires communication with Sitecore, such as getting application details and calling SitecoreAI APIs, only works in the extension points.
Next steps
You've now displayed your app in Sitecore, set up communication between the two, and made your first query. Next, you can:
- Continue developing your app:
- If your app needs to interact with the SitecoreAI APIs, initialize the
xmcpackage. - If your app needs to interact with AI skills APIs, initialize the
aipackage. - Make more queries to retrieve data from Sitecore.
- Make mutations to change data in Sitecore.
- If your app needs to interact with the SitecoreAI APIs, initialize the
- Learn more about the Marketplace SDK with the reference documentation.
- Explore other tasks to complete after you finish building your app.