@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
@@ -2,18 +2,54 @@
2
2
 
3
3
  > Two ways to put React in front of Laravel, and when each is the right one.
4
4
 
5
- Inertia and a BAP both let a Laravel application keep its routes, its
6
- controllers or classes, its auth and its models, and put React in front. They
7
- differ in where the page is made.
5
+ Inertia and a BAP both let a Laravel application keep its routes, its classes,
6
+ its auth and its models, and put React in front. They differ in where the page
7
+ is made.
8
8
 
9
- **Inertia** keeps the page in Laravel. A controller loads the data and hands
10
- it to a React component as props; the browser renders it, and server-side
11
- rendering is an optional second process. React is a view layer.
9
+ ## The same page, both ways
12
10
 
13
- **A BAP** — [Backend-Answered Pages](/hosts/backend-answered-pages) — puts a
14
- renderer in front. Pages are React Server Components; one that needs data
15
- calls into Laravel with `rpc()`, and Laravel answers that call, the session's
16
- guards and the server actions. React owns the page.
11
+ **Inertia** keeps the page in Laravel. A controller loads the data and hands it
12
+ to a React component as props:
13
+
14
+ ```php title="routes/web.php"
15
+ Route::get('/orders', fn () => Inertia::render('Orders', [
16
+ 'orders' => auth()->user()->orders()->latest()->take(5)->get(),
17
+ ]));
18
+ ```
19
+
20
+ ```tsx title="resources/js/Pages/Orders.tsx"
21
+ export default function Orders({ orders }: { orders: Order[] }) {
22
+ return <ul>{orders.map((o) => <li key={o.id}>{o.number}</li>)}</ul>
23
+ }
24
+ ```
25
+
26
+ The browser renders it, and server-side rendering is an optional second
27
+ process. React is the view layer.
28
+
29
+ **A BAP**, [Backend-Answered Pages](/hosts/backend-answered-pages), puts a
30
+ renderer in front. The page is a React Server Component, and it asks Laravel
31
+ for what it needs:
32
+
33
+ ```php title="app/Rsc/Orders.php"
34
+ class Orders
35
+ {
36
+ public function recent(int $limit = 5): array
37
+ {
38
+ return auth()->user()->orders()->latest()->take($limit)->get()->all();
39
+ }
40
+ }
41
+ ```
42
+
43
+ ```tsx title="resources/js/app/orders/page.tsx"
44
+ export default async function Orders() {
45
+ const orders = await rpc('Orders.recent', 5) // typed from the PHP signature
46
+
47
+ return <ul>{orders.map((o) => <li key={o.id}>{o.number}</li>)}</ul>
48
+ }
49
+ ```
50
+
51
+ Laravel answers that call, the session's guards and the server actions. React
52
+ owns the page.
17
53
 
18
54
  ## At a glance
19
55
 
@@ -26,41 +62,47 @@ guards and the server actions. React owns the page.
26
62
  | JavaScript a page ships | All of it: every page is a client component | Only the interactive parts |
27
63
  | Types between PHP and TypeScript | Written by hand, or generated by a separate tool | Generated from the PHP signatures on every build |
28
64
  | Processes in production | Laravel, plus an SSR server if you use one | Laravel and the renderer, always |
29
- | Where a request goes first | Laravel | The renderer, which forwards what it does not own |
65
+ | Where a request goes first | Laravel | The renderer, which forwards what it doesn't own |
30
66
  | What you learn | Laravel and React | Laravel, React Server Components, and where code runs |
31
67
 
32
- ## Choose Inertia when
68
+ ## When to choose Inertia
33
69
 
34
70
  - You want the mature, well-trodden option and a large community to ask.
35
71
  - Your pages are mostly behind a login and not worth storing at build time.
36
72
  - Your team knows Laravel deeply and wants React only as the view.
37
73
  - You would rather not run a second process in production.
38
74
 
39
- ## Choose a BAP when
75
+ ## When to choose a BAP
40
76
 
41
- - A slow part of a page should not hold back the rest: dashboards, feeds,
42
- pages that read several services.
43
- - Some pages are the same for everyone — marketing, docs, pricing — and
44
- should be served from disk or a CDN with nothing ships but HTML.
77
+ - A slow part of a page shouldn't hold back the rest: dashboards, feeds, pages
78
+ that read several services.
79
+ - Some pages are the same for everyone, such as marketing, docs and pricing,
80
+ and should be served from disk or a CDN as plain HTML.
45
81
  - You want the contract between PHP and TypeScript generated, so removing a
46
82
  field in PHP fails the typecheck where it was used.
47
83
  - You want to ship less JavaScript: server components send none.
48
84
 
49
- ## What the BAP asks of you
85
+ ## What a BAP asks of you
50
86
 
51
87
  - **Know where code runs.** Server components run in the renderer, client
52
- components in the browser, your functions in Laravel. Most confusion in a
88
+ components in the browser, and your classes in Laravel. Most confusion in a
53
89
  BAP is a question about which of the three a line is in.
54
90
  - **Accept a younger contract.** Every adapter is checked by a
55
- [conformance suite](/hosts/your-own-backend#before-you-ship-the-conformance-suite),
91
+ [conformance suite](/hosts/your-own-backend/conformance),
56
92
  but it is pre-1.0, and a mismatch at the boundary is still possible.
57
- - **Run the renderer.** It is a Node or Bun process beside PHP; deployment is
58
- [two processes](/hosts/laravel#production).
93
+ - **Run the renderer.** It is a Node or Bun process beside PHP. Deployment is
94
+ [two processes](/hosts/laravel/production).
59
95
 
60
96
  ## Moving between them
61
97
 
62
98
  Nothing in Laravel is Inertia-specific except the controllers that return
63
99
  `Inertia::render`. A BAP reaches the same models and policies through
64
- `app/Rsc` classes, so a move is page by page: a React tree's page wins its
65
- url, and every url it does not have is still Laravel's. See
66
- [Coming from Inertia](/coming-from-inertia).
100
+ `app/Rsc` classes, so you can move page by page. A React page wins its URL, and
101
+ every URL it doesn't have is still Laravel's:
102
+
103
+ ```text
104
+ resources/js/app/orders/page.tsx /orders is now the BAP's
105
+ routes/web.php every other route is still Inertia's
106
+ ```
107
+
108
+ See [Coming from Inertia](/coming-from-inertia).