Getting started
Quickstart
From an empty project to remote content in your app in under five minutes.
This guide takes you from nothing to an Expo app that renders content managed in UnitCMS. It should take less than five minutes.
1. Create a project
Open the dashboard and create a project. You get a project ID like proj_123 and three environments: development, staging and production. Each has its own content, config, flags and keys.
2. Define a content type
Content types describe the shape of your content. For this guide, create an articles type with a few fields.
| Field | Type |
|---|---|
title | Text |
slug | Text |
body | Rich Text |
coverImage | Image |
3. Add content
Go to Content, create an entry and press Publish. Drafts are never returned by the delivery API, so publishing is what makes it visible to your app.
4. Install the SDK
npx expo install @unitcms/react-native @react-native-async-storage/async-storageCopy a delivery key from API. Delivery keys are read-only and safe to include in your app.
import { Unit } from "@unitcms/react-native"
export const unit = Unit({
project: "proj_123",
token: "unit_prod_pub_..."
})5. Fetch
import { useEffect, useState } from "react"
import { Text, View } from "react-native"
import { unit } from "../lib/unit"
export default function Home() {
const [titles, setTitles] = useState<string[]>([])
useEffect(() => {
unit.content("articles").list({ limit: 10 }).then((res) => {
setTitles(res.data.map((a) => a.attributes.title))
})
}, [])
return (
<View>
{titles.map((t) => <Text key={t}>{t}</Text>)}
</View>
)
}6. Change it remotely
Edit the entry in the dashboard and publish again. The next time your app refreshes, the new content appears. No build, no review, no release.
Tip
Run the app, switch on airplane mode and reload. You will still see your content, served from the local cache withmeta.source set to "offline".