Skip to main content

Studio Local Development — Hello Current User

Build a page that displays Hello, the signed-in member's name using the Soln SDK. This guide covers creating a local folder, querying tenant data, previewing locally, saving source and publishing. The online AI assistant can retrieve this guide with system.help.search and system.help.read (docId: integration/studio-local-development).

Identity and execution​

The browser calls callAction('getCurrentUser', {}) from @soln/studio. The declared server action receives (payload, context) and reads await context.member.current() through the SDK. Its result is { data: Record<string, unknown> } or null; the built-in member name is data.so_name, not a top-level name. The example validates the name and returns only { name } to the page. Do not send profile email or other unnecessary fields to the browser, hard-code a name, or accept a page-supplied member ID as the current identity.

During sl studio dev, the actor is the CLI logged-in member. In online editor previews and mounted pages, the actor is the member invoking the page action. Runtime authorization and tenant isolation apply in both environments. On the demo tenant, signing in as the member named One produces Hello, One; the name in this sentence is an example, not source data.

The AI uses CLI/Runtime commands: SL_COMMANDS → strict input schema → executeSlCommand → Runtime domain/repository → tenant database. It does not route commands through legacy MCP tools. The browser invokes only declared page actions. The online assistant can author the same files with Studio workspace commands; creating local folders and running sl studio dev happen on the developer computer.

Create a local folder​

Install the Soln CLI and authenticate to the intended tenant first; see CLI. Confirm the account and tenant with sl whoami --json. The Runtime must support system.studio.draft.preview and system.studio.draft.execute; local preview requires the Studio entitlement and Studio asset management permission.

mkdir studio-projects
cd studio-projects
sl studio init page --dir ./hello-member --code hello-member --name "Hello Member"
cd hello-member
mkdir -p src/server

Keep the generated package.json, tsconfig.json and src/soln-studio.d.ts. For local editor completion and type checking, run npm install. Runtime compilation supplies the supported browser packages; uploading node_modules or a Vite build is unnecessary. Browser dependencies are limited to the Studio package allowlist. Server actions run on the tenant Runtime, not in a local Node server.

Hello example source​

Replace the manifest and add the following files. For an existing project, preserve its actual assetId, code, other files and unrelated settings; add the action to settings.serverActions rather than replacing unrelated actions.

soln.extension.json​

{
"schemaVersion": 1,
"code": "hello-member",
"name": "Hello Member",
"assetType": "page",
"runtimeType": "client_page",
"entryFilePath": "src/App.tsx",
"settings": {
"extensionPoints": [],
"permissions": [],
"serverActions": [
{ "name": "getCurrentUser", "entryFilePath": "src/server/get-current-user.ts" }
]
}
}

src/shared.ts​

export type CurrentUser = { name: string };

src/server/get-current-user.ts​

import type { CurrentUser } from '../shared';

type Context = {
member: {
current(): Promise<{ data: Record<string, unknown> } | null>;
};
};

export default async function getCurrentUser(
_payload: unknown,
context: Context,
): Promise<CurrentUser> {
const member = await context.member.current();
if (!member) throw new Error('CURRENT_MEMBER_REQUIRED');
const name = member.data.so_name;
if (typeof name !== 'string' || !name.trim()) {
throw new Error('CURRENT_MEMBER_NAME_REQUIRED');
}
return { name: name.trim() };
}

src/i18n.ts​

const en = {
title: 'Hello',
greeting: 'Hello, {name}',
loading: 'Loading current user…',
error: 'Unable to load the current user. Check your sign-in and permissions.',
};

const messages: Record<string, typeof en> = {
en,
'zh-CN': {
title: 'Hello',
greeting: 'Hello, {name}',
loading: '正在读取当前用户…',
error: '无法读取当前用户,请检查登录状态和权限。',
},
};

export function getMessages(locale: string) {
return messages[locale] ?? en;
}

src/App.tsx​

import { useEffect, useState } from 'react';
import { callAction, useLocale } from '@soln/studio';
import { getMessages } from './i18n';
import type { CurrentUser } from './shared';

export default function App() {
const text = getMessages(useLocale());
const [user, setUser] = useState<CurrentUser | null>(null);
const [failed, setFailed] = useState(false);

useEffect(() => {
let active = true;
callAction<Record<string, never>, CurrentUser>('getCurrentUser', {}).then(
value => { if (active) setUser(value); },
() => { if (active) setFailed(true); },
);
return () => { active = false; };
}, []);

return (
<p
role={failed ? 'alert' : 'status'}
style={{
display: 'grid', placeItems: 'center', minHeight: '100dvh', margin: 0,
fontFamily: 'system-ui, sans-serif', fontSize: 32, lineHeight: 1.5,
textAlign: 'center',
}}
>
{failed ? text.error : user ? text.greeting.replace('{name}', user.name) : text.loading}
</p>
);
}

Start local preview​

sl studio deploy --dir . --json
sl studio dev --dir . --port 5173 --locale en

The first deploy creates and compiles an unpublished tenant draft and writes its asset ID into the local manifest. Publishing is unnecessary for local development. Open the loopback URL printed by dev. The page should display Hello, <current member name>. Saving local source automatically recompiles it through the connected Runtime and reloads the page. A failed build blocks actions from the previous snapshot. Restart dev after changing CLI identity, tenant or Runtime origin.

dev does not save source or publish versions. Its actions use live tenant data, so SDK writes have real effects. Tokens stay in the local CLI process. The bridge binds to 127.0.0.1, validates Host and Origin and uses a random session URL. It exposes neither database credentials, arbitrary SQL, nor an arbitrary command/API proxy. Action input is limited to 1 MiB with at most eight concurrent actions. The snapshot permits 199 project source files plus its generated manifest.

Local preview supports callAction, locale and runtime context; theme is null. Account/password/personalization APIs, device location and form-container effects need the online host and explicitly reject locally. The server SDK retains the connected Runtime's method, permission and outbound HTTP restrictions. See Soln SDK.

Save source and release​

Stop dev with Ctrl+C, then save the finished source:

sl studio deploy --dir . --json

Deploy saves and compiles the draft; it never implicitly publishes. Publish only when a release is intended:

sl studio publish --dir . --json

Test a mounted online page while signed in as its intended member. Its Hello name comes from that online member, which can differ from the CLI member. Publication alone does not configure visitor routing or replace the built-in homepage.

Guidance for the online assistant​

Search/read this topic before explaining local development. For an online authoring request, inspect the actual asset and current workspace, add the manifest action and source files, then compile. Save and publish only as requested. Do not claim to have run commands on a developer computer or infer successful SDK execution from compilation alone. Verify the action result using the actual caller before reporting a working name lookup.

Use the published page as a member homepage​

Publishing makes a Studio version available; it does not assign the page to users. Create a configuration in Integration → Pages, select the published asset and applicability, then enable the configuration. See Custom Pages. The initial administrator remains excluded, so check the result with an applicable non-initial member.