Top-Level API

The top-level API is the main entry point to the world of Scrivito.

At the most basic level you can configure the SDK and provide models for your pages, widgets and resources. You can define React components for page and widget rendering and utilize read and write methods for page navigation.

Copy
// We start by setting up the credentials
Scrivito.configure({ tenant: "123456789abcdef0123456789abcdef" });

// Then we define our first page model -- a landing page
Scrivito.provideObjClass('LandingPage', {
  attributes: {
    title: "string",    
    body: "widgetlist",  
  },
});

// Now, let's instruct Scrivito how to render our landing page with React
Scrivito.provideComponent('LandingPage', ({ page }) =>
  <div>
    <Scrivito.ContentTag content={ page } attribute="title" tag="h1" />
    <Scrivito.ContentTag content={ page } attribute="body" />
  </div>
);

Editors are now able to create and edit landing pages using the “Create page” menu action.

There are no widgets available for the page body yet, but this is just a matter of calling provideWidgetClass, which works exactly like provideObjClass.

Method summary