Requires the
entities bundle. A project without the entities bundle returns 403 database/tables-not-available for entity endpoints. comments and collections build on entities and require it too. See Bundles.- Created by your users (or your backend) directly in Sublay, which stores and serves them
- Organized into Spaces
- Published immediately or saved as drafts for later publishing
- Enriched with file attachments, images, keywords, mentions, location, and custom metadata
- Linked to records you already keep in your own database, through a
foreignId
Creating Entities
An entity starts in Sublay.useCreateEntity creates one; a signed-in user’s entity is theirs:
id — loading it, listing it, commenting on it, reacting to it. For a complete walkthrough, see Build your first Sublay app.
How Entities Work
The standard pattern for working with a single entity is via theEntityProvider + useEntity pair. Wrap a component tree with EntityProvider (for example <EntityProvider entityId={entity.id}>) to load and provide entity state, then access that state from any child component using useEntity.
For browsing lists of entities, use useEntityList. See Entity Lists.
Link Entities to Records You Already Have
When the item your users interact with already lives in your own database — an article in your CMS, a product in your catalog — give its Sublay entity aforeignId: your own ID for that record. You can then find the entity by that ID instead of storing Sublay’s id next to your record.
createIfNotFound creates the entity the first time it’s looked up. That entity has no author, and the project’s Who can create entities without an author setting decides who may create one. See useFetchEntityByForeignId. Comment sections take foreignId and createIfNotFound the same way.
In This Section
EntityProvider & useEntity
Load a single entity by ID, foreign ID, or short ID. Access its state and perform updates and deletes from any child component.
Drafts & Publishing
Create entities as drafts, list the current user’s drafts, and publish them when ready.
Hooks
useCreateEntity
Create a new entity with optional file and image uploads.
useUpdateEntity
Update an entity’s title, content, keywords, attachments, or metadata.
useDeleteEntity
Delete an entity.
The include Parameter
The entity fetch hooks accept an optional include parameter that populates related data: one value or an array of values. Each endpoint accepts only the values it supports — drafts don’t take "topComments" or "saved", collection entities don’t take "saved" — and an unknown value is rejected with 400:

