Skip to main content

Introduction

Manage website pages and mobile app screens with dynamic content.

More information about the module's user interface https://doc.oneentry.cloud/docs/category/pages


🎯 What does this module do?

The Pages module lets you retrieve and manage pages (for websites) or screens (for mobile apps) with all their content - title, HTML/plain content, visibility, and custom attributes. You author pages in the OneEntry admin panel and fetch them dynamically in your app, so changing content in the admin goes live without redeploying.

🚀 Quickstart

Initialize the module from defineOneEntry:


const { Pages } = defineOneEntry(
"your-project-url", {
"token": "your-app-token"
}
);

Fetch a single page by its URL (marker) and read its fields:

// Fetch the "about" page in English.
const page = await Pages.getPageByUrl("about", "en_US");

console.log(page.id, page.localizeInfos.title);
console.log("Visible:", page.isVisible);

// Custom fields you defined live in attributeValues.
console.log(page.attributeValues);

Most read methods follow the same shape: an identifier (url or id) plus a langCode. See the Quick Reference Table below for the full set.

✨ Key Concepts

What is a Page?

A page is a content entity that represents:

  • Web: A page on your website (e.g. /about, /contact)
  • Mobile: A screen in your app (e.g. Profile Screen, Settings Screen)

Each page contains:

  • Content - title and HTML/plain content via localizeInfos
  • URL - pageUrl, the page marker used for routing and lookups
  • Visibility - the isVisible flag
  • Custom attributes - any additional fields you define in attributeValues (SEO meta is modeled as custom attributes, not a built-in field)
  • Localization - multi-language content

Page Types

OneEntry supports different page types (type), the most common being:

Typetype valueExample Use
Common Pagecommon_pageAbout, Contact, Terms
Catalog Pagecatalog_pageCatalog categories
External Pageexternal_pageLinks to external URLs
Error Pageerror_page404 / Not Found page

The full list of types is available through the GeneralTypes module.

Page Hierarchy

Pages are organized in a tree through parentId (top-level pages have parentId: null):

📁 Company
├─ About Us
├─ Team
└─ Careers

📁 Products
├─ Product Category 1
│ ├─ Product A
│ └─ Product B
└─ Product Category 2

You can fetch root pages with getRootPages() and walk down with getChildPagesByParentUrl().

📋 What You Need to Know

Two Ways to Identify Pages

MethodWhen to UseExample
By URLUser visits specific pagegetPageByUrl("about")
By IDInternal referencesgetPageById(123)

Best practice: the pageUrl is a stable marker - it is not a Next.js route path. Pass the OneEntry marker (e.g. "about"), not /en/about.

Page Structure

Every page has these key fields:

{
"id": 9,
"parentId": 8,
"pageUrl": "blog1",
"depth": 1,
"localizeInfos": {
"title": "Blog 1",
"menuTitle": "Blog 1",
"htmlContent": "",
"plainContent": ""
},
"isVisible": true,
"blocks": [],
"type": "common_page",
"templateIdentifier": null,
"attributeSetIdentifier": null,
"attributeValues": {},
"isSync": false
}

Localization

Pages support multiple languages - request a different langCode to get the same page in another language.

Custom Attributes

Add any fields to pages using AttributesSets - blog post author/date/tags, landing-page hero images, SEO meta, and so on. Read them from page.attributeValues. Learn more: AttributesSets Module.

Visibility

Use the isVisible flag to control which pages are shown to users - filter for isVisible: true in production.


📊 Quick Reference Table - Common Methods

MethodWhat It DoesWhen to Use
getPages()Get all pagesBuild sitemap, list all pages
getRootPages()Get all top-level (root) pagesBuild top-level navigation
getChildPagesByParentUrl()Get child pages by parent URLWalk a section's subtree
getBlocksByPageUrl()Get PositionBlock objects for a page by URLRender page content blocks
getConfigPageByUrl()Get settings for a page by URLRead per-page display settings
getPageById()Get a single page by IDInternal references
getPageByUrl()Get a single page by URLRender a page on a route
searchPage()Quick search for pagesSearch pages by title

❓ Common Questions (FAQ)

What's the difference between URL and ID?

  • pageUrl - the page marker used for routing (e.g. "about"). User-facing and stable across environments.
  • id - the numeric identifier. Used for internal references.

How do I build navigation from pages?

Use getRootPages() for top-level entries and getChildPagesByParentUrl() to walk down the tree, or use the dedicated Menus module for managed navigation structures.


How do I add SEO metadata to a page?

SEO is not a built-in field - model meta title/description/etc. as custom attributes in an AttributesSet, then read them from page.attributeValues.


🎓 Best Practices

  • Use pageUrl (the marker) for routing - never hardcode a framework route path as the URL.
  • Filter by isVisible: true for production.
  • Cache pages to reduce API calls; handle 404s (page not found) gracefully.
  • Read custom data from attributeValues rather than assuming built-in fields.