Skip to main content

Developers - Oversite

Oversite

Installation

To install the Perfection tools in your application, you can use the Oversite NPM package.

Install the NPM package as follows:

>_ Terminal
npm install @perfectiondev/oversite
note

Follow this tutorial to generate your API Key and retrieve your Subscription ID from the Admin Panel.

Initialize Oversite

To store your Perfection's Site Name, API Key and Subscription ID, you can create an .env.local file that should be localted at the root folder of your project. Once you have this set, you can initialize Oversite as follow:

app/components/oversite.js
"use client";
import oversite from "@perfectiondev/oversite";

export default function Oversite() {
oversite.initialize({
apiKey: process.env.NEXT_PUBLIC_PERFECTION_API_KEY,
subscription: process.env.NEXT_PUBLIC_PERFECTION_SUBSCRIPTION_ID,
site: process.env.NEXT_PUBLIC_PERFECTION_SITE_NAME,
});
}
info

As Oversite is using browser APIs, you need to use ssr option to disable server-rendering. Make sure you dynamically load Oversite component as follow: (read more details here)

app/components/oversiteNoSSR.js
import dynamic from "next/dynamic";

/** Dynamically load Oversite without SSR, only way to get access to browser APIs needed by Oversite */
export default dynamic(() => import("./oversite"), {
ssr: false,
});

Lastly, you need to load Oversite into your pages. We recommend you doing that at Root layout or Template level:

app/template.js
import Oversite from "./components/OversiteNoSSR";

export default function Template({ children }) {
return <Oversite />; //Must only be mounted on your preview enviroment
}

Integration Examples