The cms0 client setup is the same in every framework. What changes is how your app reads environment variables.
Use server-only environment variables for CMS0_API_KEY whenever possible.
Only expose a cms0 key to browser code when the key is intentionally scoped for public reads.
Next.js
src/cms0.ts
import { cms0 } from "@cms0/cms0";
export const cms = cms0<RootSchema>({
apiConfig: {
baseUrl: process.env.CMS0_API_BASE_URL,
key: process.env.CMS0_API_KEY,
},
});Use this from server components, route handlers, or server actions. Do not
expose the API key through NEXT_PUBLIC_ variables.
CLI config
The CLI config can stay framework-neutral:
cms0.config.ts
import "dotenv/config";
import { defineConfig } from "@cms0/cms0/config";
export default defineConfig({
entry: "./src/cms0.ts",
api: {
baseUrl: process.env.CMS0_API_BASE_URL,
key: process.env.CMS0_API_KEY,
},
});Adjust entry if your framework keeps the cms0 schema in a different file.
Success check
Your framework setup is correct when the app can read content without exposing private API keys to browser bundles.