picked 0.0.101-next.2 → 0.0.101

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.
Files changed (175) hide show
  1. package/README.md +27 -12
  2. package/docs/explanation/conditions-and-the-logic-engine.md +94 -0
  3. package/docs/explanation/content-references.md +99 -0
  4. package/docs/explanation/feature-flag-allocation.md +218 -0
  5. package/docs/explanation/how-picked-works.md +124 -0
  6. package/docs/explanation/how-pickedql-works.md +76 -0
  7. package/docs/explanation/pages-and-flows.md +64 -0
  8. package/docs/explanation/the-content-model.md +87 -0
  9. package/docs/explanation/the-two-apis.md +68 -0
  10. package/docs/explanation/why-server-side-rendering.md +76 -0
  11. package/docs/explanation/workspaces-and-versions.md +71 -0
  12. package/docs/how-to/add-a-step-field-or-action.md +56 -0
  13. package/docs/how-to/analytics/index.md +324 -0
  14. package/docs/how-to/archive-or-delete-a-workspace.md +59 -0
  15. package/docs/how-to/authenticate-the-cli.md +101 -0
  16. package/docs/how-to/authenticate-with-a-magic-link.md +56 -0
  17. package/docs/how-to/authenticate-with-a-password.md +68 -0
  18. package/docs/how-to/authenticate-with-an-api-key.md +60 -0
  19. package/docs/how-to/authenticate-with-oauth.md +49 -0
  20. package/docs/how-to/build-a-flow.md +106 -0
  21. package/docs/how-to/call-an-external-api-from-a-workflow.md +116 -0
  22. package/docs/how-to/connect-the-mcp-server.md +46 -0
  23. package/docs/how-to/create-a-content-entry.md +58 -0
  24. package/docs/how-to/create-a-project.md +40 -0
  25. package/docs/how-to/create-an-experience.md +51 -0
  26. package/docs/how-to/create-and-revoke-an-api-key.md +54 -0
  27. package/docs/how-to/debug-with-the-chrome-extension.md +57 -0
  28. package/docs/how-to/define-a-page-layout.md +54 -0
  29. package/docs/how-to/fill-and-publish-a-page.md +82 -0
  30. package/docs/how-to/install-the-gtm-template.md +84 -0
  31. package/docs/how-to/install-the-sdk.md +93 -0
  32. package/docs/how-to/install-the-vite-plugin.md +69 -0
  33. package/docs/how-to/invite-and-remove-members.md +45 -0
  34. package/docs/how-to/point-one-entry-at-another.md +75 -0
  35. package/docs/how-to/preview-a-workspace.md +39 -0
  36. package/docs/how-to/publish-a-workspace.md +42 -0
  37. package/docs/how-to/read-a-feature-flag.md +113 -0
  38. package/docs/how-to/read-a-referenced-entry.md +109 -0
  39. package/docs/how-to/register-a-component.md +55 -0
  40. package/docs/how-to/register-an-action-handler.md +85 -0
  41. package/docs/how-to/register-an-api-that-uses-oauth2.md +107 -0
  42. package/docs/how-to/render-a-step-form.md +131 -0
  43. package/docs/how-to/render-an-unpublished-preview.md +41 -0
  44. package/docs/how-to/retry-a-failed-call-with-a-loop.md +81 -0
  45. package/docs/how-to/reuse-a-section.md +64 -0
  46. package/docs/how-to/reuse-a-step-field-or-action.md +39 -0
  47. package/docs/how-to/roll-back-a-published-version.md +39 -0
  48. package/docs/how-to/run-an-ab-test.md +59 -0
  49. package/docs/how-to/run-code-on-a-form-submission.md +125 -0
  50. package/docs/how-to/server-render-a-page.md +81 -0
  51. package/docs/how-to/set-a-content-security-policy.md +32 -0
  52. package/docs/how-to/set-up-mfa.md +126 -0
  53. package/docs/how-to/switch-workspaces.md +122 -0
  54. package/docs/how-to/upload-and-use-an-asset.mdx +87 -0
  55. package/docs/how-to/validate-a-field.md +52 -0
  56. package/docs/how-to/wait-for-an-action-response.md +182 -0
  57. package/docs/how-to/write-a-condition.md +57 -0
  58. package/docs/how-to/write-a-predicate.md +60 -0
  59. package/docs/index.md +59 -0
  60. package/docs/reference/dashboard/actions.mdx +65 -0
  61. package/docs/reference/dashboard/api-keys.mdx +47 -0
  62. package/docs/reference/dashboard/conditions.mdx +51 -0
  63. package/docs/reference/dashboard/content/asset-library.mdx +74 -0
  64. package/docs/reference/dashboard/content/blocks.mdx +66 -0
  65. package/docs/reference/dashboard/content/content-entries.mdx +109 -0
  66. package/docs/reference/dashboard/content/models.mdx +119 -0
  67. package/docs/reference/dashboard/content/pages.mdx +72 -0
  68. package/docs/reference/dashboard/experiences.mdx +61 -0
  69. package/docs/reference/dashboard/external-apis.md +182 -0
  70. package/docs/reference/dashboard/features.mdx +165 -0
  71. package/docs/reference/dashboard/fields.mdx +120 -0
  72. package/docs/reference/dashboard/flow-builder/canvas.mdx +58 -0
  73. package/docs/reference/dashboard/flow-builder/condition-builder.md +69 -0
  74. package/docs/reference/dashboard/flow-builder/keyboard-shortcuts.md +72 -0
  75. package/docs/reference/dashboard/flow-builder/nodes.md +74 -0
  76. package/docs/reference/dashboard/labels.md +321 -0
  77. package/docs/reference/dashboard/lead-search.md +235 -0
  78. package/docs/reference/dashboard/projects.mdx +53 -0
  79. package/docs/reference/dashboard/reports.mdx +53 -0
  80. package/docs/reference/dashboard/steps.mdx +47 -0
  81. package/docs/reference/dashboard/team-management.md +38 -0
  82. package/docs/reference/dashboard/workflow-runs.md +157 -0
  83. package/docs/reference/dashboard/workflow-templates.md +182 -0
  84. package/docs/reference/dashboard/workflow-test-runs.md +85 -0
  85. package/docs/reference/dashboard/workspace-versioning.mdx +42 -0
  86. package/docs/reference/dashboard/workspaces.mdx +91 -0
  87. package/docs/reference/delivery-api/experience-content.md +152 -0
  88. package/docs/reference/delivery-api/index.md +45 -0
  89. package/docs/reference/delivery-api/preview-caching-crawling.md +79 -0
  90. package/docs/reference/delivery-api/project-config.md +65 -0
  91. package/docs/reference/delivery-api/workspace-schema.md +107 -0
  92. package/docs/reference/glossary.md +201 -0
  93. package/docs/reference/management-api/authentication.md +87 -0
  94. package/docs/reference/management-api/authorization-and-scopes.md +291 -0
  95. package/docs/reference/management-api/error-handling.md +232 -0
  96. package/docs/reference/management-api/pagination.md +192 -0
  97. package/docs/reference/management-api/schema/action.md +261 -0
  98. package/docs/reference/management-api/schema/analytics-session.md +363 -0
  99. package/docs/reference/management-api/schema/analytics.md +73 -0
  100. package/docs/reference/management-api/schema/api-key.md +170 -0
  101. package/docs/reference/management-api/schema/auth.md +1177 -0
  102. package/docs/reference/management-api/schema/cms-fields.md +954 -0
  103. package/docs/reference/management-api/schema/cms-models.md +1155 -0
  104. package/docs/reference/management-api/schema/common.md +362 -0
  105. package/docs/reference/management-api/schema/condition.md +254 -0
  106. package/docs/reference/management-api/schema/design-system.md +199 -0
  107. package/docs/reference/management-api/schema/experience.md +1098 -0
  108. package/docs/reference/management-api/schema/external-api.md +637 -0
  109. package/docs/reference/management-api/schema/feature.md +350 -0
  110. package/docs/reference/management-api/schema/feedback.md +103 -0
  111. package/docs/reference/management-api/schema/field.md +400 -0
  112. package/docs/reference/management-api/schema/index.md +243 -0
  113. package/docs/reference/management-api/schema/integration.md +272 -0
  114. package/docs/reference/management-api/schema/label.md +349 -0
  115. package/docs/reference/management-api/schema/lead.md +340 -0
  116. package/docs/reference/management-api/schema/mcp-server.md +299 -0
  117. package/docs/reference/management-api/schema/metric.md +223 -0
  118. package/docs/reference/management-api/schema/operation.md +96 -0
  119. package/docs/reference/management-api/schema/organization.md +749 -0
  120. package/docs/reference/management-api/schema/project.md +607 -0
  121. package/docs/reference/management-api/schema/report.md +243 -0
  122. package/docs/reference/management-api/schema/saved-view.md +288 -0
  123. package/docs/reference/management-api/schema/shopify.md +795 -0
  124. package/docs/reference/management-api/schema/step.md +273 -0
  125. package/docs/reference/management-api/schema/tenant-branding.md +185 -0
  126. package/docs/reference/management-api/schema/workbench.md +246 -0
  127. package/docs/reference/management-api/schema/workflow-run.md +263 -0
  128. package/docs/reference/management-api/schema/workflow.md +1110 -0
  129. package/docs/reference/management-api/schema/workspace-version.md +823 -0
  130. package/docs/reference/management-api/schema/workspace.md +917 -0
  131. package/docs/reference/pickedql/data-sources.md +174 -0
  132. package/docs/reference/pickedql/dimensions.md +103 -0
  133. package/docs/reference/pickedql/filtering.md +64 -0
  134. package/docs/reference/pickedql/index.md +18 -0
  135. package/docs/reference/pickedql/schema.md +172 -0
  136. package/docs/reference/pickedql/virtual-functions.md +248 -0
  137. package/docs/reference/sdk/actions.md +154 -0
  138. package/docs/reference/sdk/analytics-events.md +453 -0
  139. package/docs/reference/sdk/conditions.md +147 -0
  140. package/docs/reference/sdk/content-security-policy.md +21 -0
  141. package/docs/reference/sdk/content.md +253 -0
  142. package/docs/reference/sdk/experiences.md +51 -0
  143. package/docs/reference/sdk/features.md +256 -0
  144. package/docs/reference/sdk/fields.md +255 -0
  145. package/docs/reference/sdk/index.md +68 -0
  146. package/docs/reference/sdk/plugins/create-experience.md +123 -0
  147. package/docs/reference/sdk/plugins/dynamic-experiences.md +74 -0
  148. package/docs/reference/sdk/plugins/fingerprintjs.md +39 -0
  149. package/docs/reference/sdk/plugins/hotjar.md +60 -0
  150. package/docs/reference/sdk/plugins/index.md +33 -0
  151. package/docs/reference/sdk/plugins/sentry.md +51 -0
  152. package/docs/reference/sdk/plugins/shopify.md +109 -0
  153. package/docs/reference/sdk/plugins/window-object.md +25 -0
  154. package/docs/reference/sdk/predicates.md +43 -0
  155. package/docs/reference/sdk/react.md +61 -0
  156. package/docs/reference/sdk/ssr/index.md +33 -0
  157. package/docs/reference/sdk/ssr/rendering-and-hydration.md +103 -0
  158. package/docs/reference/sdk/ssr/serialize.md +80 -0
  159. package/docs/reference/sdk/ssr/slots-and-placements.md +113 -0
  160. package/docs/reference/sdk/steps.md +86 -0
  161. package/docs/reference/sdk/svelte.md +74 -0
  162. package/docs/reference/sdk/type-generation.md +265 -0
  163. package/docs/reference/tools/admin-api-client.md +89 -0
  164. package/docs/reference/tools/chrome-extension.md +16 -0
  165. package/docs/reference/tools/cli.md +319 -0
  166. package/docs/reference/tools/delivery-api-client.md +60 -0
  167. package/docs/reference/tools/image-optimisation-service.md +104 -0
  168. package/docs/reference/tools/mcp-run.md +121 -0
  169. package/docs/reference/tools/mcp.md +391 -0
  170. package/docs/reference/tools/vite-plugin.md +163 -0
  171. package/docs/tutorials/first-api-call.md +253 -0
  172. package/docs/tutorials/first-experience-in-the-dashboard.mdx +160 -0
  173. package/docs/tutorials/first-experience.mdx +254 -0
  174. package/docs/tutorials/first-server-rendered-page.mdx +186 -0
  175. package/package.json +8 -7
@@ -0,0 +1,391 @@
1
+ ---
2
+ type: reference
3
+ layout: docs
4
+ ---
5
+
6
+ # MCP server
7
+
8
+ Control your Picked workspace from an AI tool that writes code, with the Model
9
+ Context Protocol (MCP).
10
+
11
+ ## Tools
12
+
13
+ Each tool has its own section. Link to a tool with its name as the anchor, for example
14
+ `/reference/tools/mcp#create_feature`.
15
+
16
+ ### Discovery
17
+
18
+ #### `list_projects`
19
+
20
+ Lists your organizations and projects. Call it first: each other tool needs a project ID or a workspace ID.
21
+
22
+ #### `list_workspaces`
23
+
24
+ Lists the workspaces in a project.
25
+
26
+ #### `get_workspace_overview`
27
+
28
+ Reads the live version of the project, and the draft of a workspace with its experiences, features, steps and fields.
29
+
30
+ #### `get_project_context`
31
+
32
+ Reads the brief that the project owner wrote about the project, its goals and its entry points.
33
+
34
+ #### `guide_create_organisation`
35
+
36
+ Gives the link to create an organization in the dashboard. The MCP server cannot create an organization.
37
+
38
+ #### `guide_create_project`
39
+
40
+ Gives the link to create a project in the dashboard. The MCP server cannot create a project.
41
+
42
+ ### Documentation
43
+
44
+ #### `get_schema_info`
45
+
46
+ Reads the rules for an entity type, and the format of a flow graph. Call it before the first change to that type.
47
+
48
+ #### `list_picked_docs`
49
+
50
+ Lists every Picked documentation page with its URL.
51
+
52
+ #### `read_picked_doc`
53
+
54
+ Reads one documentation page, or one section of it.
55
+
56
+ ### Experiences
57
+
58
+ #### `list_experiences`
59
+
60
+ Lists the experiences in a workspace.
61
+
62
+ #### `get_experience`
63
+
64
+ Reads an experience, with its flow graph.
65
+
66
+ #### `create_experience`
67
+
68
+ Creates an experience.
69
+
70
+ #### `update_experience_flow`
71
+
72
+ Creates, updates, or deletes steps, conditions, actions, fields, nodes, and edges as one operation.
73
+
74
+ #### `guide_delete_experience`
75
+
76
+ Gives the link to the experience in the dashboard, where you delete it.
77
+
78
+ ### Steps, fields, conditions, and actions
79
+
80
+ #### `list_steps`
81
+
82
+ Lists the steps in a workspace.
83
+
84
+ #### `get_step`
85
+
86
+ Reads a step, with its fields.
87
+
88
+ #### `update_step`
89
+
90
+ Renames a step, or binds it to the content entry that it renders.
91
+
92
+ #### `guide_delete_step`
93
+
94
+ Gives the link to the step in the dashboard, where you delete it.
95
+
96
+ #### `list_fields`
97
+
98
+ Lists the fields in a workspace. A step ID filters the list.
99
+
100
+ #### `get_field`
101
+
102
+ Reads a field, with its options and the steps that use it.
103
+
104
+ #### `guide_delete_field`
105
+
106
+ Gives the link to the field in the dashboard, where you delete it.
107
+
108
+ #### `list_conditions`
109
+
110
+ Lists the conditions in a workspace.
111
+
112
+ #### `get_condition`
113
+
114
+ Reads a condition, with its JSON Logic rule.
115
+
116
+ #### `list_actions`
117
+
118
+ Lists the actions in a workspace.
119
+
120
+ #### `get_action`
121
+
122
+ Reads an action.
123
+
124
+ ### Feature flags
125
+
126
+ #### `list_features`
127
+
128
+ Lists your feature flags, with the variants of each one.
129
+
130
+ #### `get_feature`
131
+
132
+ Reads a feature flag.
133
+
134
+ #### `create_feature`
135
+
136
+ Creates a feature flag.
137
+
138
+ #### `update_feature`
139
+
140
+ Updates the name, description, state, or weight of a feature flag.
141
+
142
+ ### Content
143
+
144
+ #### `list_content_models`
145
+
146
+ Lists the content models in a workspace.
147
+
148
+ #### `get_content_model`
149
+
150
+ Reads a content model, with its field schema.
151
+
152
+ #### `create_content_model`
153
+
154
+ Creates a content model.
155
+
156
+ #### `update_content_model`
157
+
158
+ Renames a content model, or changes its schema. A schema change migrates the entries of the model.
159
+
160
+ #### `list_content_blocks`
161
+
162
+ Lists the content blocks in a workspace.
163
+
164
+ #### `get_content_block`
165
+
166
+ Reads a content block, with its field schema.
167
+
168
+ #### `create_content_block`
169
+
170
+ Creates a content block.
171
+
172
+ #### `update_content_block`
173
+
174
+ Renames a content block, or changes its schema. The entries do not change.
175
+
176
+ #### `list_content_entries`
177
+
178
+ Lists the content entries in a workspace. Give the ID of a content model to show only its entries.
179
+
180
+ #### `get_content_entry`
181
+
182
+ Reads a content entry, with its data.
183
+
184
+ #### `create_content_entry`
185
+
186
+ Creates a content entry of a content model.
187
+
188
+ #### `update_content_entry`
189
+
190
+ Changes the data of a content entry.
191
+
192
+ #### `guide_delete_content_entry`
193
+
194
+ Gives the link to the content entry in the dashboard, where you delete it.
195
+
196
+ #### `validate_workspace_content_entries`
197
+
198
+ Checks each content entry of a workspace against its schema, and names each entry that is not valid. It changes nothing.
199
+
200
+ ### Assets
201
+
202
+ #### `list_assets`
203
+
204
+ Lists the assets of a project.
205
+
206
+ #### `get_asset`
207
+
208
+ Reads an asset, with its file name, type, size and version.
209
+
210
+ #### `init_asset_upload`
211
+
212
+ Gives a URL to upload the file of an asset to.
213
+
214
+ #### `commit_asset_upload`
215
+
216
+ Records the asset after you upload its file.
217
+
218
+ ### Design systems
219
+
220
+ #### `list_design_systems`
221
+
222
+ Lists the design systems of a project.
223
+
224
+ #### `get_design_system`
225
+
226
+ Reads a design system, with the asset that holds its guidance.
227
+
228
+ #### `create_design_system`
229
+
230
+ Creates a design system from a Markdown asset.
231
+
232
+ #### `update_design_system`
233
+
234
+ Renames a design system, or replaces its Markdown asset.
235
+
236
+ ### Workflows
237
+
238
+ A workflow runs a graph of nodes when its trigger occurs. The trigger is a domain
239
+ event or one action.
240
+
241
+ #### `list_workflows`
242
+
243
+ Lists the workflows in a workspace, with search and sort.
244
+
245
+ #### `get_workflow`
246
+
247
+ Reads a workflow, with its trigger, graph, warnings, and the paths that its nodes use.
248
+
249
+ #### `list_workflow_tools`
250
+
251
+ Lists the tools that a tool node can run, with the arguments of each tool.
252
+
253
+ #### `create_workflow`
254
+
255
+ Creates a workflow with its trigger. You cannot change the trigger after this step.
256
+
257
+ #### `update_workflow`
258
+
259
+ Renames a workflow, and sets its visit cap.
260
+
261
+ #### `update_workflow_graph`
262
+
263
+ Creates, updates, or deletes nodes and edges as one operation.
264
+
265
+ #### `guide_delete_workflow`
266
+
267
+ Gives the link to the workflow in the dashboard, where you delete it.
268
+
269
+ #### `list_workflow_runs`
270
+
271
+ Lists the runs of a workflow, with the newest run first.
272
+
273
+ #### `get_workflow_run`
274
+
275
+ Reads the status of a run and the reason for a failure.
276
+
277
+ #### `list_workflow_run_tasks`
278
+
279
+ Lists the nodes that a run started, and the leads and labels that each node changed.
280
+
281
+ #### `test_run_workflow`
282
+
283
+ Runs the draft of a workflow one time as a test, and shows what each node did.
284
+
285
+ If `update_workflow_graph` refuses a change, it saves nothing. The result names each
286
+ node or edge that has a problem. If the origin node does not connect to a node, the
287
+ change is saved, and the result gives a warning for that node.
288
+
289
+ A workflow run uses the published version of the workflow. Publish the workspace to
290
+ apply a change.
291
+
292
+ `test_run_workflow` runs the draft, so you can test a change before you publish it. Give
293
+ the `responses` of the action, or the `entity_id` of the event. The result shows the
294
+ input, the output, the status, and the branch of each node.
295
+
296
+ A tool that reads, such as `search_leads` or an `http` `GET`, runs. A tool that writes
297
+ does not run: the result shows what it would send. A wait node does not wait. The test
298
+ run saves nothing. You must have each scope that the workflow uses.
299
+
300
+ ### Leads
301
+
302
+ #### `list_lead_fields`
303
+
304
+ Lists the fields that you can use to search the leads of a project. These are the
305
+ response keys and the labels of the newest leads. For each field, it gives the number of
306
+ leads that have it. It gives only the names of the fields, not the values.
307
+
308
+ #### `search_leads`
309
+
310
+ Gives the number of leads that match a search, and a link to the leads list in the
311
+ dashboard. It does not give the leads. Use `list_lead_fields` first to get the fields
312
+ that you can search by.
313
+
314
+ ### Publish
315
+
316
+ #### `get_preview_url`
317
+
318
+ Makes a preview URL for your unpublished work.
319
+
320
+ #### `guide_publish_workspace`
321
+
322
+ Gives the link to publish the workspace in the dashboard. The MCP server cannot publish.
323
+
324
+ #### `guide_workspace_version_publish`
325
+
326
+ Gives the link to restore a published version in the dashboard.
327
+
328
+ #### `list_workspace_versions`
329
+
330
+ Lists the published versions of a project, and shows the live one.
331
+
332
+ #### `compare_workspace_versions`
333
+
334
+ Shows the differences between the live version, a version, and a draft.
335
+
336
+ The `list_*` and `get_*` tools read the workspace draft. The draft can be
337
+ different from the live version that visitors see. Use
338
+ `compare_workspace_versions` to see what is live and what changes when you publish.
339
+
340
+ ### Code
341
+
342
+ These tools let an agent call many tools in one step.
343
+
344
+ #### `picked_run`
345
+
346
+ Runs JavaScript in which each tool above is a function on the `tools` object. Only the value that the code returns comes back. See [MCP run tool](/reference/tools/mcp-run) for the arguments, examples and limits.
347
+
348
+ #### `picked_search_api`
349
+
350
+ Finds the tools that match the words you give, for use in `picked_run`.
351
+
352
+ #### `picked_describe_api`
353
+
354
+ Gives the arguments and the result of each tool that you name, for use in `picked_run`.
355
+
356
+ ### Reports
357
+
358
+ #### `submit_feedback`
359
+
360
+ Sends a report about a problem in the MCP server to the Picked team.
361
+
362
+ :::note
363
+ A PickedQL query is not available through the MCP server at this time.
364
+ :::
365
+
366
+ ## Example prompts
367
+
368
+ - "List my Picked projects and show me the options on each one"
369
+ - "Create a feature flag called 'new-checkout' at 50% traffic"
370
+ - "Create an experience with a step that collects an email address"
371
+ - "Make a preview URL for my workspace on `https://example.com`"
372
+ - "Create a workflow that adds the label `plan.pro` to each lead from the sign-up action"
373
+ - "Show me why the last run of my workflow failed"
374
+ - "Test my sign-up workflow with the email `a@example.com` and show me what each node does"
375
+
376
+ ## Tips
377
+
378
+ - Ask your agent for a list of your projects first. Then ask it to read your
379
+ workspace and report the options on each record.
380
+ - For a large experience, ask your agent about flow graphs and JSON Logic. The agent
381
+ can read the documentation for you.
382
+ - An update to an experience flow is atomic. Your agent can create steps, fields,
383
+ nodes, and edges in one operation.
384
+ - See a preview of your work on your site before you publish, to check that each page
385
+ is correct.
386
+ - The `create_workflow` prompt tells your agent how to build a workflow. The resource
387
+ `picked://workflow/{workflowId}/graph` gives the graph of a workflow as JSON.
388
+
389
+ ## Related
390
+
391
+ - [How to connect the MCP server](/how-to/connect-the-mcp-server)
@@ -0,0 +1,163 @@
1
+ ---
2
+ type: reference
3
+ layout: docs
4
+ ---
5
+
6
+ # Vite Plugin
7
+
8
+ `@picked/vite-plugin-picked` adds Picked to your Vite project. It reads the options
9
+ of your project at build time. It then puts them in a module that gives them to the
10
+ SDK, so the SDK makes no API request at runtime. In development it also serves a
11
+ launcher page. On that page you can see a preview of an experience with your own
12
+ feature flag values.
13
+
14
+ ## How it works
15
+
16
+ ### Build-time config injection
17
+
18
+ When Vite starts, in both `dev` and `build`, the plugin does this:
19
+
20
+ 1. It reads the configuration of your project from the Picked API.
21
+ 2. It embeds those options in your bundle.
22
+ 3. The module gives the options to the SDK as the browser loads it.
23
+ 4. The SDK reads the embedded configuration at runtime and makes no network request.
24
+
25
+ Step 3 is a function call. The module gives the options to the SDK as it loads, and does
26
+ not wait for the SDK to ask.
27
+
28
+ When a preview token is there at runtime, the SDK ignores the embedded configuration and
29
+ reads fresh data from the API.
30
+
31
+ ### Preload of the data file
32
+
33
+ Vite puts the options of your project in their own JavaScript file. For each HTML page
34
+ in your build, the plugin adds a `<link rel="modulepreload">` for that file. The
35
+ browser then gets it while it reads the page, and not later when the SDK starts.
36
+
37
+ The CMS content of an experience stays in its own file and gets no preload. The
38
+ browser gets it only when an experience needs it.
39
+
40
+ Some applications make their HTML from the code, and not from an HTML file in your
41
+ project. React Router in server mode is one of these. Such a build has no page for the
42
+ plugin to add the link to. Add this line to the code that runs in the browser instead:
43
+
44
+ :::code-group
45
+
46
+ ```ts [entry.client.ts]
47
+ import 'virtual:picked/data'
48
+ ```
49
+
50
+ :::
51
+
52
+ Your framework then sees the file in its own list and adds the preload for you.
53
+
54
+ The line reads no value from the module. It is there for the work the module does as it
55
+ loads. A bundler removes a module that only declares values, and removes the line with
56
+ it. This module gives your project options to the SDK, which is work, so the bundler
57
+ keeps both.
58
+
59
+ Your application is correct without this line. The SDK gets the same data later, as it
60
+ starts. The line moves that work earlier.
61
+
62
+ ### Types for the data file
63
+
64
+ The plugin makes `virtual:picked/data` at build time. Because the module is not a file in
65
+ your project, TypeScript cannot find its types. The plugin gives you a type file for the
66
+ module. Point your project at that type file to import from the module:
67
+
68
+ :::code-group
69
+
70
+ ```json [tsconfig.json]
71
+ {
72
+ "compilerOptions": {
73
+ "types": ["@picked/vite-plugin-picked/client"]
74
+ }
75
+ }
76
+ ```
77
+
78
+ ```ts [picked-data.ts]
79
+ /// <reference types="@picked/vite-plugin-picked/client" />
80
+ ```
81
+
82
+ :::
83
+
84
+ Use one of the two. The `types` option applies to all files in your project. The
85
+ `reference` comment applies to one file.
86
+
87
+ The module gives three values: `projectConfig`, `experienceContent` and
88
+ `manifestMetadata`. You do not give these values to the SDK. The module gives them to
89
+ the SDK itself as the browser loads it.
90
+
91
+ ### Dev launcher
92
+
93
+ In development, the plugin serves an HTML page at `/`. On that page you can:
94
+
95
+ - see every feature flag in your project with its current state;
96
+ - turn a feature flag on or off for a local test;
97
+ - see a preview of an experience with your own feature flag values.
98
+
99
+ After the dev server starts, the launcher URL appears next to the Vite output:
100
+
101
+ ```
102
+ ➜ Picked: http://localhost:5173/
103
+ ➜ Local: http://localhost:5173/
104
+ ➜ Network: use --host to expose
105
+ ```
106
+
107
+ ## Options
108
+
109
+ Project identity belongs in [`picked.config.ts`](/reference/sdk/type-generation). The two
110
+ options that carry it are deprecated, and the table marks them.
111
+
112
+ | Option | Type | Default | Description |
113
+ | ---------------- | --------------------- | ------------------------ | ---------------------------------------------------------- |
114
+ | `disableLauncher`| `boolean` | `false` | Turns the launcher page off in both dev and build output. |
115
+ | `generateTypes` | `boolean` | `true` | Whether the plugin writes types from the workspace schema. |
116
+ | `mode` | `'bundle' \| 'api'` | `'bundle'` | Whether the build carries your project data. |
117
+ | `projectId` | `string` | — | **Deprecated.** Use `picked.config.ts`. |
118
+ | `apiUrl` | `string` | — | **Deprecated.** Use `picked.config.ts`. |
119
+
120
+ ### projectId and apiUrl
121
+
122
+ These two options moved to [`picked.config.ts`](/reference/sdk/type-generation), which the
123
+ `picked` command and type generation also read. A later release removes them.
124
+
125
+ The plugin still reads an option for a field that `picked.config.ts` leaves out, so a
126
+ project that has yet to move needs no change. It stops when the two values are different,
127
+ rather than choose one for you.
128
+
129
+ ### generateTypes
130
+
131
+ The plugin reads the workspace schema and writes `picked-env.d.ts`, on `vite dev` and on
132
+ `vite build`. [Type generation](/reference/sdk/type-generation) describes the output and
133
+ the `picked.config.ts` options that control it.
134
+
135
+ A failure stops the run. Set `generateTypes: false` for a build that must not write types,
136
+ such as a build for one more entry point.
137
+
138
+ ### mode
139
+
140
+ `'bundle'` reads your project options at build time and puts them in your bundle.
141
+
142
+ `'api'` does not read them. Your build then makes no request to the Picked API, and
143
+ writes no `.picked` directory. The SDK reads your project options from the API at
144
+ runtime instead. Use this when your build must not depend on the Picked API.
145
+
146
+ The SDK has no equivalent option. It uses the data your build gives it, and the API when
147
+ your build gives none.
148
+
149
+ ## Build output
150
+
151
+ For a production build, `vite build`, the plugin writes an `index.html` file that
152
+ holds the launcher page. Set `disableLauncher` to stop this. The file lets you deploy
153
+ the launcher next to your application, so that a stakeholder can see a preview.
154
+
155
+ The plugin writes that file only when your build made no `index.html` of its own. An
156
+ application that has an HTML entry keeps its own page at the root of the output.
157
+
158
+ The plugin also writes a `.picked` directory next to your Vite `root`. It holds the
159
+ options of your project and the CMS content of each experience.
160
+
161
+ ## Related
162
+
163
+ - [How to install the Vite plugin](/how-to/install-the-vite-plugin)