Core concepts
Developer preview
Read this page before you write code with the SDK. It tells you the Uniform terms, and where each term shows up in a Next.js app. For the full product glossary, refer to the composition glossary.
The big picture#
- Authors build pages in Uniform from the components that you define. They do not write code.
- Developers write a React component for each component type, and connect the app to Uniform with the SDK.
- The SDK finds the composition for each URL, and renders it with your React components.
Content model#
Component#
A component is a building block of a page, for example a hero, a card or a page. In Uniform, you define the component type in the component library. In your app, you write a React component for each type, and map the two in resolveComponent.
| In Uniform | In your code |
|---|---|
Component type, with a public ID, for example hero | component.type === "hero" in resolveComponent |
| Component instance | The props of your React component (ComponentProps) |
For the props, parameters and slots in code, refer to Components and slots in code.
Parameter#
A parameter is a value of a component, for example a title, an image or a link. Authors set the values. Your component gets each value as a ComponentParameter<T> in parameters, and reads it in .value.
Slot#
A slot is a named container for child components, for example header, content or footer. The component type defines which components authors can put in each slot. Your component renders a slot with UniformSlot:
Composition#
A composition is a tree of components with one root component. For a website, a composition is usually one page. The root component type is a composition component, for example page. Its slots contain the other components.
Pattern#
A pattern is a reusable part of a composition. Authors can use a component pattern in many compositions. When an author changes the pattern, all compositions that use it change. Canvas shows a pattern alone on the playground route of your app. Refer to Patterns.
Entry#
An entry is structured content of a content type, for example a blog post or a product. A component can show the data of an entry. Refer to Entries.
Composition state#
A composition has a draft state and a published state. Visitors see the published state. Canvas shows the draft state. The SDK uses these numbers:
| State | Value | Used for |
|---|---|---|
| Published | 64 | Visitors |
| Draft | 0 | Preview in Canvas |
| Editor | 63 | Visual editing in Canvas |
Routing#
Project map#
The project map is the tree of URLs of a project. Each project map node has a path, for example /about, and can have a composition. The SDK uses the Uniform Route API to find the node and the composition for each URL. Refer to Project maps.
| In Uniform | In your code |
|---|---|
A node with a static path, for example /about | A request to /about renders its composition. |
A node with a dynamic segment, for example /products/:slug | context.dynamicInputs.slug in your components |
| A redirect | The page sends a redirect. |
| No node for the path | The page calls notFound(). |
The code#
The middleware writes the route path and the state of the request into a short string: the code. Then it rewrites the request to app/uniform/[code]/page.tsx. The code contains no visitor data, so all visitors of a published route share one cached page. Refer to How it works.
Personalization#
Uniform Context#
Uniform Context is the engine that classifies a visitor and chooses the content for the visitor. It runs in the browser, and in edge mode also in the middleware. It uses the Context manifest, which contains the signals, tests and other settings that you publish in Uniform. Refer to Manifest.
| Term | Meaning | In your code |
|---|---|---|
| Signal | A rule that adds a score to the visitor when the visitor does something, for example opens a URL with a campaign query string. | None. Uniform evaluates it. |
| Score | The value of a visitor dimension, for example interest in a topic. | useScores() |
| Quirk | A fact about the visitor, for example the country. | useQuirks(), the quirks middleware option |
| Enrichment | A score from the categories of the content that the visitor views. | None. Uniform evaluates it. |
| Consent | Permission to store the visitor data. | defaultConsent in the server configuration |
Refer to Signals, Quirks and Enrichments.
Personalization, A/B tests and visibility rules#
| Feature | What authors do | What the SDK does |
|---|---|---|
| Personalization | Put a personalization component in a slot, with variants for different visitors. | Shows the variants that match the visitor. |
| A/B test | Put a test component in a slot, with variants and a distribution. | Gives each visitor one variant, and keeps it. |
| Visibility rules | Add rules to a component, for example "show only in Canada". | Shows the component in the browser when its rules match. |
You do not write code for these features. The SDK renders the $personalization and $test components for you. Refer to Personalization and A/B tests.
Lite mode and edge mode#
| Lite mode | Edge mode | |
|---|---|---|
| Who chooses the variants | The browser, after hydration | The edge middleware, before the browser gets the page |
| What the visitor sees first | The default variants | The variants of the visitor |
Refer to Edge mode execution.
Authoring#
Canvas and visual editing#
Canvas is the visual editor of Uniform. It shows your app in a preview panel. Authors select components on the page and edit them. Refer to Visual editing.
| Term | Meaning | In your code |
|---|---|---|
| Preview URL | The URL that Canvas opens: /api/preview of your app. | app/api/preview/route.ts |
| Draft mode | The Next.js mode that shows draft content. The preview handler turns it on. | draftMode() from next/headers |
| Playground | The route that shows a pattern alone. | app/playground/[code]/page.tsx |
| Editing markers | HTML markers that tell Canvas where each component is. The SDK adds them in the editor state. | None |
Webhooks#
When an author publishes content, Uniform sends a webhook to your app. The SDK revalidates the cached pages that use the content. Refer to Caching.
Next steps#
- Write the code for your components: Components and slots in code
- Build your first page: Tutorial
- Select the setup for your app: Choose a setup