Write content
Page and layout writes need site credentials plus Authorization: Bearer <jwt> from a signed-in editor.
Create a page in Next.js
In a server action module, use the session cookie to obtain a JWT:
'use server';
import { cookies } from 'next/headers';import { StormyCMSClient } from '@stormycms/core';
export async function createAboutPage(layoutId: string) { const client = new StormyCMSClient(); const jwt = await client.getJWTToken((await cookies()).toString()); if (!jwt) throw new Error('Sign in before creating a page');
const now = new Date().toISOString(); return client.createPage(jwt, { slug: 'about', metadata: { title: 'About', description: '', keywords: [] }, components: [ { name: 'Heading', props: [{ name: 'text', value: 'About' }], }, ], layoutId, createdAt: now, updatedAt: now, });}Pass an existing layout ID. The layout needs an Outlet, and Heading must exist in your component export map.
Page updates replace the component tree. Include every component you want to retain.
For raw GraphQL, use the mutation signatures and inputs. Media record writes use site credentials and require a separate file upload.
Last updated: 10/20/26, 1:09 AM