0.5.1 • Published 19 days ago
@sitecore-cloudsdk/core v0.5.1
core
This package is for initializing the Cloud SDK and its other packages in your app.
Installation
npm install @sitecore-cloudsdk/core
To initialize other Cloud SDK packages, first install them:
npm install @sitecore-cloudsdk/events
npm install @sitecore-cloudsdk/personalize
Usage
- Import the modules of all installed Cloud SDK packages that you want to initialize.
- Initialize the Cloud SDK and its packages using the
CloudSDK
function, available in thecore
package.
Code examples
Initialize the Cloud SDK and its packages on the browser side:
'use client';
import { useEffect } from 'react';
import { CloudSDK } from '@sitecore-cloudsdk/core/browser';
import '@sitecore-cloudsdk/events/browser';
import '@sitecore-cloudsdk/personalize/browser';
export default function Home() {
useEffect(() => {
CloudSDK({
sitecoreEdgeContextId: '<YOUR_CONTEXT_ID>',
siteName: '<YOUR_SITE_NAME>',
enableBrowserCookie: true
})
.addEvents() // Initialize the `events` package.
.addPersonalize({ enablePersonalizeCookie: true, webPersonalization: true }) // Initialize the `personalize` package and enable web personalization.
.initialize();
}, []);
return <></>;
}
Initialize the Cloud SDK and its packages on the server side:
import type { NextRequest, NextResponse } from 'next/server';
import { CloudSDK } from '@sitecore-cloudsdk/core/server';
import '@sitecore-cloudsdk/events/browser';
import '@sitecore-cloudsdk/personalize/browser';
export async function middleware(request: NextRequest) {
const response = NextResponse.next();
await CloudSDK(request, response, {
sitecoreEdgeContextId: '<YOUR_CONTEXT_ID>',
siteName: '<YOUR_SITE_NAME>',
enableServerCookie: true
})
.addEvents() // Initialize the `events` package.
.addPersonalize({ enablePersonalizeCookie: true }) // Initialize the `personalize` package.
.initialize();
return response;
}
Documentation
0.5.1-rc.0
3 months ago
0.5.0-rc.0
5 months ago
0.5.2-rc.0
19 days ago
0.4.4
6 months ago
0.5.0
5 months ago
0.4.1
8 months ago
0.4.3
7 months ago
0.5.1
3 months ago
0.4.2
7 months ago
0.4.0
8 months ago
0.4.0-rc.1
8 months ago
0.4.0-rc.0
9 months ago
0.3.1-rc.1
12 months ago
0.3.1-rc.0
12 months ago
0.3.1
12 months ago
0.3.0
1 year ago
0.2.4
1 year ago
0.2.3
1 year ago
0.2.2
1 year ago
0.2.1
1 year ago
0.1.5
1 year ago
0.2.0
1 year ago
0.1.4
1 year ago
0.1.3
1 year ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago
0.1.0-rc.5
2 years ago
0.1.0-rc.4
2 years ago
0.1.0-rc.3
2 years ago
0.1.0-rc.2
2 years ago
0.1.0-rc.0
2 years ago