Skip to content
BuildBase

Reusable content blocks in the console

Write a content block in the console, read it by its slug from your app, change its wording without a deploy, and see what deleting one breaks.

A content block is a named piece of formatted text your app shows wherever it likes: a refund policy, an announcement, a pricing footnote. Your code asks for it by its slug, so the wording can change in the console without a deploy. This guide writes Acme Analytics' refund policy.

Before you start

A console role that can create, update and delete content blocks, and room on your plan for content blocks.

1. Open Content blocks

Open Content blocks in the console

(opens the console in a new tab)

In the left rail choose Content, then Content blocks under Pages. When your plan caps content blocks, a meter beside Create shows how many you have used. Press Create.

The Content blocks page under Content, with the Content blocks menu item highlighted as step 1 and the Create button as step 2

2. Write it

In Create content block, fill Give it a title and Give it a slug, the name your code uses, such as refund-policy. Write the text under Content and press Create.

The Create content block dialog: Refund policy, the slug refund-policy highlighted as step 2, and the policy text

3. Change its wording

Press Edit on its row, change the text and press Update. Pages that read it show the new text the next time they fetch it; nothing needs a deploy.

The Edit content block dialog with the new wording, and the Update button highlighted as step 3

4. Delete it

The bin on its row asks first, and says what breaks: any page that loads the block by its slug stops showing it. Delete cannot be undone.

The Delete content block dialog: Any page that loads this block by its slug will stop showing it, highlighted as step 4, and the Delete button

Check it works

Read it by its slug with your org API key:

curl https://api.console.buildbase.app/api/rich-content/slug/refund-policy \
  -H "Authorization: Bearer $BUILDBASE_TOKEN"

Or with the server client from @buildbase/sdk/server:

const policy = await content.richContent.get('refund-policy');

An unknown slug answers 404, and the server client returns null.

Things to watch out for

  • The slug is the address your code uses. Renaming it breaks every page that loads the block.
  • Delete cannot be undone.
  • Your plan caps how many blocks you keep. Create is refused at the limit.

Next Steps