@picked/client 0.0.101-next.2 → 0.0.101-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -158
- package/dist/{api-AaQeg3Ij.cjs → api-9o_emCM5.cjs} +1 -1
- package/dist/{api-BlRFU0Fi.js → api-BbQt8aW3.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/server/index.js +2 -2
- package/dist/{plugin-CVD2TnRC.cjs → plugin-I8_6ncy_.cjs} +1 -1
- package/dist/{plugin-DhznDG-h.js → plugin-uZJ45vK6.js} +2 -2
- package/dist/{preview-unavailable-xWLCr93y.cjs → preview-unavailable-BUNxTYLe.cjs} +1 -1
- package/dist/{preview-unavailable-mW4Pj3Ph.js → preview-unavailable-BYFD2a58.js} +1 -1
- package/dist/{provider-zag5m5GH.cjs → provider-Bzi_Kb-n.cjs} +1 -1
- package/dist/{provider-COb_V-yq.js → provider-CQKp0iUJ.js} +1 -1
- package/package.json +5 -5
- package/dist/docs/_root.css +0 -101
- package/dist/docs/explanation/conditions-and-the-logic-engine.md +0 -94
- package/dist/docs/explanation/content-references.md +0 -99
- package/dist/docs/explanation/feature-flag-allocation.md +0 -218
- package/dist/docs/explanation/how-picked-works.md +0 -124
- package/dist/docs/explanation/how-pickedql-works.md +0 -76
- package/dist/docs/explanation/pages-and-flows.md +0 -64
- package/dist/docs/explanation/the-content-model.md +0 -87
- package/dist/docs/explanation/the-two-apis.md +0 -68
- package/dist/docs/explanation/why-server-side-rendering.md +0 -76
- package/dist/docs/explanation/workspaces-and-versions.md +0 -71
- package/dist/docs/how-to/add-a-step-field-or-action.md +0 -43
- package/dist/docs/how-to/analytics/index.md +0 -316
- package/dist/docs/how-to/archive-or-delete-a-workspace.md +0 -46
- package/dist/docs/how-to/authenticate-the-cli.md +0 -101
- package/dist/docs/how-to/authenticate-with-a-magic-link.md +0 -47
- package/dist/docs/how-to/authenticate-with-a-password.md +0 -59
- package/dist/docs/how-to/authenticate-with-an-api-key.md +0 -51
- package/dist/docs/how-to/authenticate-with-oauth.md +0 -40
- package/dist/docs/how-to/build-a-flow.md +0 -93
- package/dist/docs/how-to/call-an-external-api-from-a-workflow.md +0 -102
- package/dist/docs/how-to/connect-the-mcp-server.md +0 -46
- package/dist/docs/how-to/create-a-content-entry.md +0 -48
- package/dist/docs/how-to/create-a-project.md +0 -29
- package/dist/docs/how-to/create-an-experience.md +0 -42
- package/dist/docs/how-to/create-and-revoke-an-api-key.md +0 -42
- package/dist/docs/how-to/debug-with-the-chrome-extension.md +0 -57
- package/dist/docs/how-to/define-a-page-layout.md +0 -46
- package/dist/docs/how-to/fill-and-publish-a-page.md +0 -66
- package/dist/docs/how-to/install-the-gtm-template.md +0 -84
- package/dist/docs/how-to/install-the-sdk.md +0 -93
- package/dist/docs/how-to/install-the-vite-plugin.md +0 -69
- package/dist/docs/how-to/invite-and-remove-members.md +0 -35
- package/dist/docs/how-to/point-one-entry-at-another.md +0 -61
- package/dist/docs/how-to/preview-a-workspace.md +0 -28
- package/dist/docs/how-to/publish-a-workspace.md +0 -30
- package/dist/docs/how-to/read-a-feature-flag.md +0 -113
- package/dist/docs/how-to/read-a-referenced-entry.md +0 -109
- package/dist/docs/how-to/register-a-component.md +0 -55
- package/dist/docs/how-to/register-an-action-handler.md +0 -85
- package/dist/docs/how-to/register-an-api-that-uses-oauth2.md +0 -107
- package/dist/docs/how-to/render-a-step-form.md +0 -131
- package/dist/docs/how-to/render-an-unpublished-preview.md +0 -41
- package/dist/docs/how-to/retry-a-failed-call-with-a-loop.md +0 -81
- package/dist/docs/how-to/reuse-a-section.md +0 -53
- package/dist/docs/how-to/reuse-a-step-field-or-action.md +0 -28
- package/dist/docs/how-to/roll-back-a-published-version.md +0 -26
- package/dist/docs/how-to/run-an-ab-test.md +0 -49
- package/dist/docs/how-to/run-code-on-a-form-submission.md +0 -125
- package/dist/docs/how-to/server-render-a-page.md +0 -81
- package/dist/docs/how-to/set-a-content-security-policy.md +0 -32
- package/dist/docs/how-to/set-up-mfa.md +0 -113
- package/dist/docs/how-to/switch-workspaces.md +0 -122
- package/dist/docs/how-to/upload-and-use-an-asset.mdx +0 -73
- package/dist/docs/how-to/validate-a-field.md +0 -52
- package/dist/docs/how-to/wait-for-an-action-response.md +0 -182
- package/dist/docs/how-to/write-a-condition.md +0 -45
- package/dist/docs/how-to/write-a-predicate.md +0 -60
- package/dist/docs/index.md +0 -59
- package/dist/docs/reference/dashboard/actions.mdx +0 -56
- package/dist/docs/reference/dashboard/api-keys.mdx +0 -38
- package/dist/docs/reference/dashboard/conditions.mdx +0 -42
- package/dist/docs/reference/dashboard/content/asset-library.mdx +0 -63
- package/dist/docs/reference/dashboard/content/blocks.mdx +0 -57
- package/dist/docs/reference/dashboard/content/content-entries.mdx +0 -95
- package/dist/docs/reference/dashboard/content/models.mdx +0 -108
- package/dist/docs/reference/dashboard/content/pages.mdx +0 -61
- package/dist/docs/reference/dashboard/experiences.mdx +0 -51
- package/dist/docs/reference/dashboard/external-apis.md +0 -169
- package/dist/docs/reference/dashboard/features.mdx +0 -154
- package/dist/docs/reference/dashboard/fields.mdx +0 -106
- package/dist/docs/reference/dashboard/flow-builder/canvas.mdx +0 -58
- package/dist/docs/reference/dashboard/flow-builder/condition-builder.md +0 -57
- package/dist/docs/reference/dashboard/flow-builder/keyboard-shortcuts.md +0 -72
- package/dist/docs/reference/dashboard/flow-builder/nodes.md +0 -63
- package/dist/docs/reference/dashboard/labels.md +0 -321
- package/dist/docs/reference/dashboard/lead-search.md +0 -224
- package/dist/docs/reference/dashboard/projects.mdx +0 -44
- package/dist/docs/reference/dashboard/reports.mdx +0 -43
- package/dist/docs/reference/dashboard/steps.mdx +0 -37
- package/dist/docs/reference/dashboard/team-management.md +0 -29
- package/dist/docs/reference/dashboard/workflow-runs.md +0 -142
- package/dist/docs/reference/dashboard/workflow-templates.md +0 -182
- package/dist/docs/reference/dashboard/workflow-test-runs.md +0 -77
- package/dist/docs/reference/dashboard/workspace-versioning.mdx +0 -30
- package/dist/docs/reference/dashboard/workspaces.mdx +0 -76
- package/dist/docs/reference/delivery-api/experience-content.md +0 -152
- package/dist/docs/reference/delivery-api/index.md +0 -45
- package/dist/docs/reference/delivery-api/preview-caching-crawling.md +0 -79
- package/dist/docs/reference/delivery-api/project-config.md +0 -65
- package/dist/docs/reference/delivery-api/workspace-schema.md +0 -107
- package/dist/docs/reference/glossary.md +0 -201
- package/dist/docs/reference/management-api/authentication.md +0 -87
- package/dist/docs/reference/management-api/authorization-and-scopes.md +0 -291
- package/dist/docs/reference/management-api/error-handling.md +0 -232
- package/dist/docs/reference/management-api/pagination.md +0 -192
- package/dist/docs/reference/pickedql/data-sources.md +0 -174
- package/dist/docs/reference/pickedql/dimensions.md +0 -103
- package/dist/docs/reference/pickedql/filtering.md +0 -64
- package/dist/docs/reference/pickedql/index.md +0 -18
- package/dist/docs/reference/pickedql/schema.md +0 -172
- package/dist/docs/reference/pickedql/virtual-functions.md +0 -248
- package/dist/docs/reference/sdk/actions.md +0 -154
- package/dist/docs/reference/sdk/analytics-events.md +0 -453
- package/dist/docs/reference/sdk/conditions.md +0 -147
- package/dist/docs/reference/sdk/content-security-policy.md +0 -21
- package/dist/docs/reference/sdk/content.md +0 -253
- package/dist/docs/reference/sdk/experiences.md +0 -51
- package/dist/docs/reference/sdk/features.md +0 -256
- package/dist/docs/reference/sdk/fields.md +0 -255
- package/dist/docs/reference/sdk/index.md +0 -68
- package/dist/docs/reference/sdk/plugins/create-experience.md +0 -123
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +0 -74
- package/dist/docs/reference/sdk/plugins/index.md +0 -29
- package/dist/docs/reference/sdk/plugins/window-object.md +0 -25
- package/dist/docs/reference/sdk/predicates.md +0 -43
- package/dist/docs/reference/sdk/ssr/index.md +0 -33
- package/dist/docs/reference/sdk/ssr/rendering-and-hydration.md +0 -103
- package/dist/docs/reference/sdk/ssr/serialize.md +0 -80
- package/dist/docs/reference/sdk/ssr/slots-and-placements.md +0 -113
- package/dist/docs/reference/sdk/steps.md +0 -86
- package/dist/docs/reference/sdk/type-generation.md +0 -265
- package/dist/docs/reference/tools/chrome-extension.md +0 -16
- package/dist/docs/reference/tools/cli.md +0 -292
- package/dist/docs/reference/tools/image-optimisation-service.md +0 -104
- package/dist/docs/reference/tools/mcp.md +0 -136
- package/dist/docs/reference/tools/vite-plugin.md +0 -163
- package/dist/docs/tutorials/first-api-call.md +0 -235
- package/dist/docs/tutorials/first-experience-in-the-dashboard.mdx +0 -143
- package/dist/docs/tutorials/first-experience.mdx +0 -254
- package/dist/docs/tutorials/first-server-rendered-page.mdx +0 -186
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: tutorial
|
|
3
|
-
layout: docs
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import { Screenshot } from '../../../components/Screenshot'
|
|
7
|
-
|
|
8
|
-
# Add Picked to your application
|
|
9
|
-
|
|
10
|
-
In this tutorial we make a color survey and put it on a page. We build the flow in the
|
|
11
|
-
Picked dashboard, connect the SDK to it, and see the survey in a browser.
|
|
12
|
-
|
|
13
|
-
At the end you have one experience, one step, one field, and a page that shows them.
|
|
14
|
-
|
|
15
|
-
## Before you start
|
|
16
|
-
|
|
17
|
-
- A Picked account, and an organization in it.
|
|
18
|
-
- Node 20 or later.
|
|
19
|
-
- A web application that runs React or Svelte. A new Vite application is enough.
|
|
20
|
-
|
|
21
|
-
## 1. Make a project
|
|
22
|
-
|
|
23
|
-
A project is one site or one application.
|
|
24
|
-
|
|
25
|
-
1. Sign in to the dashboard.
|
|
26
|
-
2. Open your organization.
|
|
27
|
-
3. Click **New Project**.
|
|
28
|
-
4. Enter the name `Tutorial`.
|
|
29
|
-
5. Click **Create**.
|
|
30
|
-
|
|
31
|
-
The project home page opens. It shows a project ID near the top. Copy that ID. Every step
|
|
32
|
-
after this one needs it.
|
|
33
|
-
|
|
34
|
-
## 2. Make a field
|
|
35
|
-
|
|
36
|
-
A field collects one answer from your visitor.
|
|
37
|
-
|
|
38
|
-
1. Click **Fields** in the sidebar.
|
|
39
|
-
2. Click **New field**.
|
|
40
|
-
3. Enter the name `Color`. The dashboard fills in the label and the key for you.
|
|
41
|
-
4. Change the label to `Which color do you like most?`.
|
|
42
|
-
5. Leave the key as `color`.
|
|
43
|
-
6. Choose the type **Text**.
|
|
44
|
-
7. Click **Create field**.
|
|
45
|
-
|
|
46
|
-
<Screenshot
|
|
47
|
-
route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/fields"
|
|
48
|
-
alt="The fields list for a workspace on the Picked dashboard"
|
|
49
|
-
/>
|
|
50
|
-
|
|
51
|
-
The field now appears in the fields list.
|
|
52
|
-
|
|
53
|
-
## 3. Make the experience
|
|
54
|
-
|
|
55
|
-
1. Click **Flows** in the sidebar. The experiences list opens.
|
|
56
|
-
2. Click **New experience**.
|
|
57
|
-
3. Enter the name `Color survey`.
|
|
58
|
-
4. Leave **Type** on the **Flow** option.
|
|
59
|
-
5. Open **Advanced**.
|
|
60
|
-
6. Enter the component name `ColorSurvey`.
|
|
61
|
-
7. Click **Create flow**.
|
|
62
|
-
|
|
63
|
-
The flow builder opens with an empty canvas. One gray circle is on the left. That circle
|
|
64
|
-
is the origin, and every flow starts there.
|
|
65
|
-
|
|
66
|
-
## 4. Make a step
|
|
67
|
-
|
|
68
|
-
A step is one screen that your visitor sees. It holds your field. You make one from the
|
|
69
|
-
library, on the left of the flow builder.
|
|
70
|
-
|
|
71
|
-
1. Find the **Steps** section in the library.
|
|
72
|
-
2. Click the **+** next to it.
|
|
73
|
-
3. Enter the name `Question`. The key fills in as `question`.
|
|
74
|
-
4. Click **Create step**.
|
|
75
|
-
|
|
76
|
-
The flow builder opens again, and your step is in the library.
|
|
77
|
-
|
|
78
|
-
## 5. Build the flow
|
|
79
|
-
|
|
80
|
-
1. Find your `Question` step in the library on the left.
|
|
81
|
-
2. Drag it onto the canvas.
|
|
82
|
-
3. Drag from the output handle of the origin to the input handle of your step. An arrow
|
|
83
|
-
joins them.
|
|
84
|
-
4. Drag your `Color` field from the library onto the step node.
|
|
85
|
-
5. Click **Save** in the toolbar.
|
|
86
|
-
|
|
87
|
-
The subtitle of the step node now reads one field. Your flow is one step long, and it
|
|
88
|
-
starts at the origin.
|
|
89
|
-
|
|
90
|
-
## 6. Publish the workspace
|
|
91
|
-
|
|
92
|
-
Your visitors see nothing until you publish.
|
|
93
|
-
|
|
94
|
-
1. Click **Publish** in the workspace toolbar.
|
|
95
|
-
2. Read the change preview.
|
|
96
|
-
3. Click **Publish** to confirm.
|
|
97
|
-
|
|
98
|
-
## 7. Connect the SDK
|
|
99
|
-
|
|
100
|
-
Install the client and the adapter for your framework.
|
|
101
|
-
|
|
102
|
-
:::code-group
|
|
103
|
-
|
|
104
|
-
```bash [React]
|
|
105
|
-
npm install picked @picked/react
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
```bash [Svelte]
|
|
109
|
-
npm install picked @picked/svelte
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
:::
|
|
113
|
-
|
|
114
|
-
Now write the component that renders the step. Put it in `ColorSurvey.tsx`, or in
|
|
115
|
-
`ColorSurvey.svelte`. It reads the fields of the active step and
|
|
116
|
-
puts each one in a form.
|
|
117
|
-
|
|
118
|
-
:::code-group
|
|
119
|
-
|
|
120
|
-
```tsx [React]
|
|
121
|
-
import { useStep, useStoreGlobal } from '@picked/react/hooks'
|
|
122
|
-
|
|
123
|
-
export function ColorSurvey() {
|
|
124
|
-
const { fields, form } = useStep()
|
|
125
|
-
const currentFields = useStoreGlobal(fields)
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<form {...form.props}>
|
|
129
|
-
{currentFields.map((field) => (
|
|
130
|
-
<div key={field.id}>
|
|
131
|
-
<label htmlFor={field.id}>{field.label}</label>
|
|
132
|
-
<input
|
|
133
|
-
id={field.id}
|
|
134
|
-
name={field.id}
|
|
135
|
-
value={field.value ?? ''}
|
|
136
|
-
onChange={field.onChange}
|
|
137
|
-
onBlur={field.onBlur}
|
|
138
|
-
/>
|
|
139
|
-
</div>
|
|
140
|
-
))}
|
|
141
|
-
<button type="submit">Continue</button>
|
|
142
|
-
</form>
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
```svelte [Svelte]
|
|
148
|
-
<script lang="ts">
|
|
149
|
-
import { getStep } from '@picked/svelte/hooks'
|
|
150
|
-
|
|
151
|
-
const { fields, form } = getStep()
|
|
152
|
-
</script>
|
|
153
|
-
|
|
154
|
-
<form {...form.props}>
|
|
155
|
-
{#each $fields as field}
|
|
156
|
-
<div>
|
|
157
|
-
<label for={field.id}>{field.label}</label>
|
|
158
|
-
<input
|
|
159
|
-
id={field.id}
|
|
160
|
-
name={field.id}
|
|
161
|
-
value={field.value ?? ''}
|
|
162
|
-
onchange={field.onChange}
|
|
163
|
-
onblur={field.onBlur}
|
|
164
|
-
/>
|
|
165
|
-
</div>
|
|
166
|
-
{/each}
|
|
167
|
-
<button type="submit">Continue</button>
|
|
168
|
-
</form>
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
:::
|
|
172
|
-
|
|
173
|
-
Then start the client from `picked.ts`. Put your project ID in `projectId`. The key in `components` must
|
|
174
|
-
match the component name that you entered in step 4.
|
|
175
|
-
|
|
176
|
-
:::code-group
|
|
177
|
-
|
|
178
|
-
```tsx [React]
|
|
179
|
-
import { createClient } from 'picked'
|
|
180
|
-
import { dynamicExperiencesPlugin } from '@picked/client/plugins/dynamic-experiences'
|
|
181
|
-
import { adaptReactComponent } from '@picked/react'
|
|
182
|
-
import { reactFrameworkPlugin } from '@picked/react/plugins/framework'
|
|
183
|
-
import { ColorSurvey } from './ColorSurvey'
|
|
184
|
-
|
|
185
|
-
export const picked = createClient({
|
|
186
|
-
projectId: 'your-project-id',
|
|
187
|
-
components: {
|
|
188
|
-
ColorSurvey: adaptReactComponent(ColorSurvey),
|
|
189
|
-
},
|
|
190
|
-
plugins: [reactFrameworkPlugin({ components: {} }), dynamicExperiencesPlugin()],
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
picked.start()
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
```ts [Svelte]
|
|
197
|
-
import { createClient } from 'picked'
|
|
198
|
-
import { dynamicExperiencesPlugin } from '@picked/client/plugins/dynamic-experiences'
|
|
199
|
-
import { adaptSvelteComponent } from '@picked/svelte'
|
|
200
|
-
import { svelteFrameworkPlugin } from '@picked/svelte/plugins/framework'
|
|
201
|
-
import ColorSurvey from './ColorSurvey.svelte'
|
|
202
|
-
|
|
203
|
-
export const picked = createClient({
|
|
204
|
-
projectId: 'your-project-id',
|
|
205
|
-
components: {
|
|
206
|
-
ColorSurvey: adaptSvelteComponent(ColorSurvey),
|
|
207
|
-
},
|
|
208
|
-
plugins: [svelteFrameworkPlugin({ components: {} }), dynamicExperiencesPlugin()],
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
picked.start()
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
:::
|
|
215
|
-
|
|
216
|
-
`dynamicExperiencesPlugin` reads the published configuration of your project. It registers your
|
|
217
|
-
experience, your step, and your field. You declare none of them in code.
|
|
218
|
-
|
|
219
|
-
## 8. See it
|
|
220
|
-
|
|
221
|
-
Start your application and open it in a browser.
|
|
222
|
-
|
|
223
|
-
Your survey appears. It shows the label `Which color do you like most?` and one text
|
|
224
|
-
input. Both come from the dashboard, and neither is in your code.
|
|
225
|
-
|
|
226
|
-
## 9. Change it without a deployment
|
|
227
|
-
|
|
228
|
-
This step shows you what the dashboard controls.
|
|
229
|
-
|
|
230
|
-
1. Go back to the dashboard.
|
|
231
|
-
2. Open your `Color` field.
|
|
232
|
-
3. Change the label to `Which color do you like least?`.
|
|
233
|
-
4. Click **Save**.
|
|
234
|
-
5. Publish the workspace again.
|
|
235
|
-
6. Open the page in your browser again.
|
|
236
|
-
|
|
237
|
-
The question changes. You edited no code and you deployed nothing.
|
|
238
|
-
|
|
239
|
-
## What you built
|
|
240
|
-
|
|
241
|
-
You have an experience that you control from the dashboard and render in your own
|
|
242
|
-
application. The dashboard holds the flow, the step, and the field. Your code holds only
|
|
243
|
-
the component and the client.
|
|
244
|
-
|
|
245
|
-
To change the label, the field type, or the order of the steps, edit the workspace and
|
|
246
|
-
publish again. You deploy no code.
|
|
247
|
-
|
|
248
|
-
## Where to go next
|
|
249
|
-
|
|
250
|
-
- [Your first server-rendered page](/tutorials/first-server-rendered-page) — a page that
|
|
251
|
-
a search engine can read.
|
|
252
|
-
- [How to build a flow](/how-to/build-a-flow) — branches, actions, and conditions.
|
|
253
|
-
- [About how Picked works](/explanation/how-picked-works) — what happens between publish
|
|
254
|
-
and render.
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: tutorial
|
|
3
|
-
layout: docs
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import { Screenshot } from '../../../components/Screenshot'
|
|
7
|
-
|
|
8
|
-
# Your first server-rendered page
|
|
9
|
-
|
|
10
|
-
In this tutorial we make a landing page in the Picked CMS and render it on your server.
|
|
11
|
-
A search engine reads the content in the first response, and the browser takes over after
|
|
12
|
-
that.
|
|
13
|
-
|
|
14
|
-
At the end you have one page layout, one content entry, and a server that returns your
|
|
15
|
-
content in its HTML.
|
|
16
|
-
|
|
17
|
-
## Before you start
|
|
18
|
-
|
|
19
|
-
- A Picked project. [Add Picked to your application](/tutorials/first-experience)
|
|
20
|
-
makes one.
|
|
21
|
-
- A server that renders React or Svelte and can add a script tag to its HTML.
|
|
22
|
-
- Node 20 or later.
|
|
23
|
-
|
|
24
|
-
## 1. Model the page layout
|
|
25
|
-
|
|
26
|
-
A page layout sets which fields your page holds.
|
|
27
|
-
|
|
28
|
-
1. Open your workspace.
|
|
29
|
-
2. Click **Pages** in the sidebar, then **Page Layouts**.
|
|
30
|
-
3. Click **New model**.
|
|
31
|
-
4. Set **Category** to **Page layout**.
|
|
32
|
-
5. Enter the name `Page hero` and the key `page-hero`. The key is stable, and your SDK
|
|
33
|
-
code and your API calls both use it.
|
|
34
|
-
6. Add a **Single-line text** field with the key `title`.
|
|
35
|
-
7. Add a **Markdown** field with the key `body`.
|
|
36
|
-
8. Click **Create model**.
|
|
37
|
-
|
|
38
|
-
<Screenshot
|
|
39
|
-
route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/models"
|
|
40
|
-
alt="A page layout in the schema builder on the Picked dashboard"
|
|
41
|
-
/>
|
|
42
|
-
|
|
43
|
-
Your layout now holds two fields. It holds no content yet.
|
|
44
|
-
|
|
45
|
-
## 2. Make the page and fill it
|
|
46
|
-
|
|
47
|
-
1. Click **Pages** in the sidebar.
|
|
48
|
-
2. Click **New Experience**.
|
|
49
|
-
3. Choose the **Page** type.
|
|
50
|
-
4. Choose your `page-hero` layout.
|
|
51
|
-
5. Open the **Properties** tab.
|
|
52
|
-
6. Enter a `title` and a `body`.
|
|
53
|
-
7. Click **Save**. Picked makes a content entry and links it to the page.
|
|
54
|
-
8. Correct every field error.
|
|
55
|
-
|
|
56
|
-
## 3. Publish the workspace
|
|
57
|
-
|
|
58
|
-
1. Click **Publish** in the workspace toolbar.
|
|
59
|
-
2. Click **Publish** to confirm.
|
|
60
|
-
|
|
61
|
-
Your content is now live. Read it back with `curl`, and put your own project ID in the
|
|
62
|
-
path:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
curl https://api.picked.app/api/v1/projects/proj_123
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
The answer holds your steps. Each one carries a `layoutContentId`, which points at the
|
|
69
|
-
content entry behind it.
|
|
70
|
-
|
|
71
|
-
## 4. Make the snapshot on your server
|
|
72
|
-
|
|
73
|
-
`serialize()` finds which experiences match the URL and reads their content. It gives you
|
|
74
|
-
a snapshot as plain JSON.
|
|
75
|
-
|
|
76
|
-
Make one client for each request, in `server.ts`:
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
import { createClient } from 'picked'
|
|
80
|
-
import { serialize } from '@picked/client/server'
|
|
81
|
-
|
|
82
|
-
const client = createClient(options)
|
|
83
|
-
|
|
84
|
-
const snapshot = await serialize(client, {
|
|
85
|
-
projectConfig,
|
|
86
|
-
attributes: { location: { pathname: url.pathname } },
|
|
87
|
-
})
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Write the snapshot into your HTML answer:
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
const html = `
|
|
94
|
-
<div id="root">${appHtml}</div>
|
|
95
|
-
<script>window.__PICKED__ = ${JSON.stringify(snapshot)}</script>
|
|
96
|
-
`
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## 5. Render the slot
|
|
100
|
-
|
|
101
|
-
`<ExperienceSlot name="page" />` renders every experience that points at that slot. Give
|
|
102
|
-
the provider your snapshot, so the first paint in the browser matches the HTML from your
|
|
103
|
-
server.
|
|
104
|
-
|
|
105
|
-
Register the component under the same name that the page uses. Here it is `CMSPage`.
|
|
106
|
-
|
|
107
|
-
:::code-group
|
|
108
|
-
|
|
109
|
-
```tsx [React]
|
|
110
|
-
import type { CreateClientOptions } from 'picked'
|
|
111
|
-
import { dynamicExperiencesPlugin } from '@picked/client/plugins/dynamic-experiences'
|
|
112
|
-
import { adaptReactComponent, ExperienceSlot, PickedProvider } from '@picked/react'
|
|
113
|
-
import { reactFrameworkPlugin } from '@picked/react/plugins/framework'
|
|
114
|
-
import { useStepContent } from '@picked/react/hooks'
|
|
115
|
-
|
|
116
|
-
function CMSPage() {
|
|
117
|
-
const content = useStepContent()
|
|
118
|
-
const title = typeof content?.title === 'string' ? content.title : ''
|
|
119
|
-
return <h1>{title}</h1>
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const options = {
|
|
123
|
-
projectId: 'proj_123',
|
|
124
|
-
components: { CMSPage: adaptReactComponent(CMSPage) },
|
|
125
|
-
plugins: [reactFrameworkPlugin({ components: {} }), dynamicExperiencesPlugin()],
|
|
126
|
-
} satisfies CreateClientOptions
|
|
127
|
-
|
|
128
|
-
export function Page({ snapshot }) {
|
|
129
|
-
return (
|
|
130
|
-
<PickedProvider options={options} snapshot={snapshot}>
|
|
131
|
-
<ExperienceSlot name="page" />
|
|
132
|
-
</PickedProvider>
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
```svelte [Svelte]
|
|
138
|
-
<script lang="ts">
|
|
139
|
-
import type { CreateClientOptions } from 'picked'
|
|
140
|
-
import { dynamicExperiencesPlugin } from '@picked/client/plugins/dynamic-experiences'
|
|
141
|
-
import { adaptSvelteComponent, ExperienceSlot, setPickedContext } from '@picked/svelte'
|
|
142
|
-
import { svelteFrameworkPlugin } from '@picked/svelte/plugins/framework'
|
|
143
|
-
import CMSPage from './CMSPage.svelte'
|
|
144
|
-
|
|
145
|
-
const { snapshot } = $props()
|
|
146
|
-
|
|
147
|
-
const options = {
|
|
148
|
-
projectId: 'proj_123',
|
|
149
|
-
components: { CMSPage: adaptSvelteComponent(CMSPage) },
|
|
150
|
-
plugins: [svelteFrameworkPlugin({ components: {} }), dynamicExperiencesPlugin()],
|
|
151
|
-
} satisfies CreateClientOptions
|
|
152
|
-
|
|
153
|
-
setPickedContext({ options, snapshot })
|
|
154
|
-
</script>
|
|
155
|
-
|
|
156
|
-
<ExperienceSlot name="page" />
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
:::
|
|
160
|
-
|
|
161
|
-
Point your page experience at the slot. Set its target selector to `.picked-slot-page`,
|
|
162
|
-
and publish again.
|
|
163
|
-
|
|
164
|
-
## 6. Check that a crawler can read it
|
|
165
|
-
|
|
166
|
-
1. Read the answer from your server with `curl`, or with the view-source command of your
|
|
167
|
-
browser.
|
|
168
|
-
2. Find your `title` in the HTML.
|
|
169
|
-
|
|
170
|
-
Your title is in the first response, not in a script that the browser must run. A crawler
|
|
171
|
-
and a social preview both read it.
|
|
172
|
-
|
|
173
|
-
## What you built
|
|
174
|
-
|
|
175
|
-
You have a page whose content lives in the Picked CMS and whose HTML comes from your
|
|
176
|
-
server. An editor changes the copy in the dashboard and publishes. Your server serves the
|
|
177
|
-
new content on the next request, and you deploy nothing.
|
|
178
|
-
|
|
179
|
-
## Where to go next
|
|
180
|
-
|
|
181
|
-
- [About server-side rendering](/explanation/why-server-side-rendering) — why the
|
|
182
|
-
snapshot exists, and what it carries.
|
|
183
|
-
- [Server snapshot](/reference/sdk/ssr/serialize) — every `serialize()` parameter.
|
|
184
|
-
- [Models](/reference/dashboard/content/models) — every field type.
|
|
185
|
-
- [Preview, cache, and crawlers](/reference/delivery-api/preview-caching-crawling) — how
|
|
186
|
-
a draft stays out of the search index.
|