@rsc-kit/mcp 0.40.0 → 0.42.0

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 (60) hide show
  1. package/dist/recipes.js +37 -20
  2. package/dist/recipes.js.map +1 -1
  3. package/guides/admin-plugins.md +206 -6
  4. package/guides/api-routes.md +159 -215
  5. package/guides/authorization.md +103 -114
  6. package/guides/backend-answered-pages.md +301 -250
  7. package/guides/bap-vs-inertia.md +67 -25
  8. package/guides/blueprints.md +307 -174
  9. package/guides/bun.md +42 -25
  10. package/guides/caching.md +46 -49
  11. package/guides/coming-from-inertia.md +5 -5
  12. package/guides/commands.md +251 -200
  13. package/guides/connection.md +50 -54
  14. package/guides/content-security-policy.md +133 -84
  15. package/guides/domains.md +190 -149
  16. package/guides/edge-caching.md +242 -268
  17. package/guides/emails.md +96 -45
  18. package/guides/errors.md +116 -137
  19. package/guides/feature-flags.md +100 -30
  20. package/guides/file-uploads.md +101 -26
  21. package/guides/fonts.md +139 -110
  22. package/guides/forms.md +520 -538
  23. package/guides/images.md +87 -28
  24. package/guides/index.json +13 -33
  25. package/guides/instrumentation.md +134 -95
  26. package/guides/isr.md +3 -3
  27. package/guides/live-data-in-production.md +695 -0
  28. package/guides/live-data.md +170 -839
  29. package/guides/mcp.md +83 -59
  30. package/guides/metadata.md +124 -179
  31. package/guides/navigation.md +118 -147
  32. package/guides/no-javascript.md +49 -57
  33. package/guides/offline.md +118 -153
  34. package/guides/openapi.md +100 -35
  35. package/guides/pages.md +160 -50
  36. package/guides/ppr.md +178 -256
  37. package/guides/pwa.md +251 -218
  38. package/guides/queries.md +171 -300
  39. package/guides/react-compiler.md +90 -50
  40. package/guides/redirects.md +141 -177
  41. package/guides/response-headers.md +76 -74
  42. package/guides/route-interception.md +112 -111
  43. package/guides/routing.md +216 -322
  44. package/guides/sections.md +63 -66
  45. package/guides/seo-files.md +127 -65
  46. package/guides/server-actions.md +285 -357
  47. package/guides/static-generation.md +131 -199
  48. package/guides/testing.md +272 -150
  49. package/guides/third-party-scripts.md +94 -47
  50. package/guides/typed-routes.md +115 -113
  51. package/guides/url-validation.md +113 -61
  52. package/guides/validation.md +53 -62
  53. package/guides/view-transitions.md +159 -132
  54. package/guides/where-it-runs.md +226 -162
  55. package/package.json +2 -2
  56. package/guides/admin.md +0 -520
  57. package/guides/deployment.md +0 -598
  58. package/guides/go.md +0 -538
  59. package/guides/laravel.md +0 -786
  60. package/guides/your-own-backend.md +0 -587
package/dist/recipes.js CHANGED
@@ -114,6 +114,16 @@ A wizard keeps every step's fields in the form (hidden, not unmounted) and does
114
114
  \`onClick={async () => (await validate('email')) && setStep(2)}\`. Checking as
115
115
  it is typed is validate() in onChange - debounce it yourself.
116
116
 
117
+ STOPPING BOTS: put <Honeypot /> (import { Honeypot } from '@rsc-kit/core/honeypot')
118
+ inside any form that posts to a server action - <Form>, a plain <form action>,
119
+ with or without JS, a "use server" function or a Laravel/Go action. A post with
120
+ its hidden field filled is answered as a success and dropped BEFORE the action
121
+ runs; the trap is stripped otherwise, so the action never sees it. The field is
122
+ 'homepage'; <Honeypot name="website" /> renames it. Forms without it are not
123
+ checked. Crude spam only - add a rate limit (Laravel: throttle middleware on
124
+ the action class) for a form worth attacking. Do NOT hand-roll a hidden input
125
+ and check it in the action.
126
+
117
127
  Values are uncontrolled, so an initial one is React's own \`defaultValue\`. A
118
128
  refused submit keeps what was typed, because the DOM kept it.
119
129
 
@@ -129,7 +139,7 @@ Names that describe a shape build it: \`address.city\` nests, and
129
139
  \`items[0].name\` (or \`items[0][name]\`) makes an array of objects. That is
130
140
  the shape the schema was written against, and error() takes the same path.
131
141
 
132
- Binding a field - a rich editor, a Radix select, a value read as it is typed:
142
+ Binding a field - a rich editor, a select, a value read as it is typed:
133
143
 
134
144
  \`\`\`tsx
135
145
  <Form action={save} defaultValues={{ body: '' }}>
@@ -214,8 +224,10 @@ and point components.json at it.
214
224
 
215
225
  **shadcn/ui works as-is.** Input, Textarea, Button and Label are styled native
216
226
  elements, so \`name\` does what it always does. Select, Checkbox, Switch and
217
- RadioGroup are Radix underneath and render a hidden native control whenever
218
- given a \`name\` - omit it and they are invisible to the form.
227
+ RadioGroup render a hidden native control whenever given a \`name\`, on Base
228
+ UI and on Radix alike - omit it and they are invisible to the form. A Base UI
229
+ Select changes that control without an event; <Form> watches its controls, so
230
+ dirty and valid() still see the pick.
219
231
 
220
232
  Do NOT use shadcn's own Form/FormField/FormControl with this. Those wrap
221
233
  react-hook-form, a different system for the same job. One or the other.
@@ -1302,12 +1314,12 @@ data / validationErrors / serverError / redirected is set), so reading any
1302
1314
  field of it is safe. Do NOT wrap actions in a hook to catch
1303
1315
  ServerRedirectError; nothing throws.
1304
1316
 
1305
- A generated backend stub (Go/Laravel actions in server-actions.generated.ts) is
1317
+ A generated backend stub (Go/Laravel actions in src/server-actions/<class>.ts) is
1306
1318
  typed Promise<T | Redirected>, not an ActionResult: the redirect answer is
1307
1319
  { redirected } in place of T. Narrow with isRedirected from
1308
1320
  '@rsc-kit/core/errors' before reading it, and also before any "success" that
1309
1321
  follows an await of a void stub:
1310
- const secret = await databasesReveal(id)
1322
+ const secret = await databases.reveal(id)
1311
1323
  if (isRedirected(secret)) return
1312
1324
  Reading secret.Password first is a type error on purpose. A <Form> or
1313
1325
  useAction already skips onSuccess on a redirect.
@@ -1468,8 +1480,8 @@ WHAT EACH PIECE BECOMES
1468
1480
  router.visit / router.get -> visit(url) from @rsc-kit/core/router
1469
1481
  router.reload({ only }) -> Rsc::revalidate('orders') in the action re-renders that section with the answer
1470
1482
  router.post, useForm().post('/orders') -> a server action: php artisan make:rsc-action Orders --method=create --auth
1471
- --revalidate=orders, then <Form action={ordersCreate}> from @rsc-kit/core/form
1472
- (import ordersCreate from the generated actions module)
1483
+ --revalidate=orders, then <Form action={orders.create}> from @rsc-kit/core/form
1484
+ (import * as orders from './server-actions/orders', the module the build writes)
1473
1485
  useForm errors/processing -> <Form>'s errors (a FormRequest's ValidationException lands on the fields)
1474
1486
  and pending
1475
1487
  ->middleware(['auth','verified']) -> export const middleware = ['auth', 'verified'] in middleware.ts beside the page
@@ -1858,8 +1870,10 @@ A new app: bun create rsc-kit --backend=<url>, or rsc-kit init in an empty
1858
1870
  directory, which starts one there.
1859
1871
 
1860
1872
  The backend writes rsc-host.json at the project root (beside vite.config.ts):
1861
- { "actions": { jsName: "Function.name" }, "functions": ["Function.name", ...] }.
1862
- actions become "use server" stubs in src/server-actions.generated.ts;
1873
+ { "actions": { module: { export: "Function.name" } }, "functions": ["Function.name", ...] }.
1874
+ actions become "use server" modules, one per class: { "orders": { "create":
1875
+ "Orders.create" } } is src/server-actions/orders.ts exporting create, and an
1876
+ __invoke (or a Go function with no method) is the module's default export;
1863
1877
  functions type rpc()'s first argument, so a misspelt name fails tsc. rpc is a
1864
1878
  GLOBAL the build declares in .rsc-kit/rsc-env.d.ts - never import it. Have
1865
1879
  Vite write the manifest so it cannot go stale:
@@ -2008,8 +2022,11 @@ Server actions are classes in app/Rsc/Actions, found by reflection in PHP;
2008
2022
  functions } - and vite.config.ts runs it as dev and every build start:
2009
2023
  rscKit({ hostManifest: { command: ['php', 'artisan', 'rsc:host-manifest'] } }).
2010
2024
  functions types rpc()'s first argument, so a misspelt name fails tsc. The
2011
- build writes the "use server" stubs from actions - import ordersCancel from
2012
- the generated actions module in a client component. Rsc::revalidate('orders')
2025
+ build writes a "use server" module per class from actions - import * as
2026
+ orders from './server-actions/orders' in a client component, then
2027
+ orders.cancel(id); a nested class, Billing/Invoices, is server-actions/billing/invoices.
2028
+ An invokable class is the module's default: import sendInvite from
2029
+ './server-actions/send-invite'. server-actions/ is the build's: never edit it. Rsc::revalidate('orders')
2013
2030
  in the action returns the re-rendered region with the answer.
2014
2031
 
2015
2032
  Per url: if the React tree has it, React renders it, otherwise Laravel does
@@ -2404,7 +2421,7 @@ ROTATING is a deploy:
2404
2421
  - signing: open pages stop refreshing until reloaded; nothing else breaks.
2405
2422
  - action key: actions from pages loaded before the change fail.
2406
2423
 
2407
- Docs: /hosts/deployment#secrets.`,
2424
+ Docs: /hosts/deployment/secrets/.`,
2408
2425
  },
2409
2426
  {
2410
2427
  topic: 'env',
@@ -3020,7 +3037,7 @@ THE BACKEND'S ACTIONS AS THE FORM: when a FormRequest or a Go struct already
3020
3037
  says what a record takes, write NO schema. Give the generated actions instead
3021
3038
  of form, and the source only list/find/delete:
3022
3039
  source: { list, find, delete },
3023
- actions: { create: productsStore, update: productsUpdate },
3040
+ actions: { create: products.store, update: products.update }, // import * as products from '../server-actions/products'
3024
3041
  fields: { category_id: { relation: 'categories' } }, // the backend's names, typechecked
3025
3042
  form and actions are one or the other, never both. The create form is drawn
3026
3043
  from create's input, the edit form from update's. create(values); update(values,
@@ -3175,24 +3192,24 @@ create and update) saves the panel's records too, so source is only
3175
3192
  { list, find, delete }; one that does not needs a whole source. Say fields and
3176
3193
  actions on the blueprint, never again on the resource (that throws).
3177
3194
 
3178
- A BACKEND, WITH NO SCHEMA: defineBlueprint({ name, actions: { create: contactSend }, theme }),
3179
- with contactSend imported from the generated server-actions module - the
3195
+ A BACKEND, WITH NO SCHEMA: defineBlueprint({ name, actions: { create: send }, theme }),
3196
+ with import { send } from '../server-actions/contact' - the
3180
3197
  action itself, never its name as a string (a string throws). No form, no
3181
3198
  handle, no zod. actions is { create, update }, either or both: create's input
3182
3199
  draws the create form, update's the edit form, and update is called
3183
3200
  (values, key) - update(UpdateProfile $request, string $user) in Laravel,
3184
3201
  reading the key with $this->route('user'); func(ctx, in ProfileInput,
3185
- id string) in Go. bunx rsc-kit make:form contactSend writes forms/contact.ts.
3202
+ id string) in Go. bunx rsc-kit make:form Contact.send writes forms/contact.ts.
3186
3203
  The action is a Laravel class in app/Rsc/Actions (Contact::send is
3187
- contactSend; a class in app/Rsc is rpc only and has no action) or Go's
3188
- reg.HandleAction("contactSend", "Contact.send", fn). Fields and browser checks
3204
+ send in server-actions/contact; a class in app/Rsc is rpc only and has no action) or Go's
3205
+ reg.HandleAction("Contact.send", fn). Fields and browser checks
3189
3206
  come from what it takes (rsc-host.json): a Laravel FormRequest's rules(), or a
3190
3207
  Go struct, whose validate tags are read as hints and never run, so the Go
3191
3208
  function must still check. It takes one object; a file needs form and handle.
3192
3209
  A 422 from Laravel (a FormRequest type-hinted on the method, whose authorize()
3193
3210
  returns true) or Go (rsckit.InvalidField) lands under the same fields,
3194
3211
  uncaught. To check in TypeScript first, keep a schema and
3195
- handle: (values) => contactSend(values).
3212
+ handle: (values) => send(values).
3196
3213
 
3197
3214
  THE BOT TRAP: every form carries a hidden field named homepage. Filled in, the
3198
3215
  submission is answered as a success and dropped - handle() never runs. So a
@@ -3209,7 +3226,7 @@ which is the renderer's runtime.
3209
3226
 
3210
3227
  A THEME draws it with one component, BlueprintForm (type FormsTheme from
3211
3228
  @rsc-kit/press/forms), given action, fields, values, submit, done and
3212
- honeypot; replace it with theme: { ...shadcn, BlueprintForm: Mine }.
3229
+ honeypot (render <Honeypot name={honeypot} /> from @rsc-kit/core/honeypot); replace it with theme: { ...shadcn, BlueprintForm: Mine }.
3213
3230
  VISIBLE: fields: { company: { visible: { when: 'topic', is: 'sales' } } }
3214
3231
  shows a field only while another has one of the values in is (one or a
3215
3232
  list); not turns it round; neither means once the other is filled in or