Skip to main content

Getting Started

Get CDF into your app: know what it is and why it belongs in the stack, then install, bootstrap, and use stores the way a real home app does.

NPM Package: @espressif/rainmaker-base-cdf

For a fuller product-level picture, see the CDF Overview.


What is CDF?

CDF (Central Data Framework) is the app data layer between your UI and IoT SDKs (RainMaker, Matter, and others).

Your screens read stores and call entity methods. CDF keeps that data in sync and routes work to the active SDK through an adaptor — so feature code does not talk to raw SDK APIs.

App UI  →  CDF (stores + entities)  →  SDK adaptor  →  RainMaker / Matter / …

Why do you need it?

The RainMaker Base SDK gives you cloud and device APIs. On its own, your app still has to manage state, UI refresh, and (if needed) more than one backend.

CDF helps you avoid that boilerplate. You use one stable surface for users, devices, homes, scenes, schedules, and automations.

Without CDFWith CDF
Call SDK APIs from screensCall CDF entity methods
Maintain lists and cache yourselfRead ready-made stores
Wire push / refresh by handStores update; UI can re-render
UI locked to one SDKSame UI API across adaptors

Use the SDK alone only if you already own state management and want full control of every call.


What can it help with?

StoreWhat your app can do
userStoreSign in / out, profile
nodeStoreList devices, set parameters
groupStoreHomes, rooms, sharing
sceneStoreCreate and activate scenes
scheduleStoreTime-based actions
automationStoreEvent-driven rules
subscriptionStoreLive push updates into stores

What apps can use it?

App typeFit
React Native smart-home / IoT appsPrimary path (RainMaker Home)
React web appsSame CDF APIs via context
Other TypeScript appsConsume stores/entities directly

You still configure the Base SDK (and its platform adapters such as storage) underneath the RainMaker CDF adaptor — see Base SDK Getting Started.


What will you achieve?

By the end of this page you will:

  1. Know why CDF sits in your app stack
  2. Install and initialize CDF with an existing RainMaker adaptor
  3. Read and update data from a screen through stores

Writing custom adaptors is optional and covered later in Adaptor Registry.


1. Install

npm install @espressif/rainmaker-base-cdf

2. Bootstrap CDF (typical app path)

Most apps reuse an existing adaptor. Production examples from RainMaker Home:

Minimal shape:

import { AdaptorRegistry, initCDF } from "@espressif/rainmaker-base-cdf";
import { ESPRMBaseSDKAdaptor, ESPRMBaseAdaptorIdentifier } from "@sdk-adaptors/ESPRMBase";

const registry = AdaptorRegistry.getInstance();

registry.register(
new ESPRMBaseSDKAdaptor({
baseUrl: "https://api.rainmaker.espressif.com",
region: "us-east-1",
// Add other SDK config as needed
})
);

registry.setActiveAdaptor(ESPRMBaseAdaptorIdentifier);

const cdf = await initCDF({ sdkAdaptorRegistry: registry });

In React / React Native, expose cdf through context (the home app uses useCDF()). Feature screens then import CDF only — not the raw SDK.


3. Use CDF in a screen

List devices

import { observer } from "mobx-react-lite";

const DeviceList = observer(function DeviceList({ cdf }) {
const nodes = cdf.nodeStore.nodesList;

return (
<>
{nodes.map((node) => (
<Text key={node.id}>{node.id}</Text>
))}
</>
);
});

Wrap store-reading components with MobX observer so they re-render when CDF updates.

Control a device parameter

await node.setParam("Power", true);
// Store updates; observer components refresh

Typical feature flow

  1. Sign in → userStore
  2. Load homes / rooms → groupStore
  3. Show devices → nodeStore
  4. Toggle a light, run a scene, or edit a schedule → entity methods on the matching store

More examples: Room management · Entities · Domain stores · RainMaker Home


4. What to learn next

GoalGo here
Deeper what / why / stack pictureOverview
Feature workflowsEntities, Domain stores
Layers in detailArchitecture
Custom or multi-SDK adaptorsAdaptor Registry (advanced)
PitfallsBest practices

Resources

On this page