@rsc-kit/mcp 0.41.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.
- package/dist/recipes.js +12 -2
- package/dist/recipes.js.map +1 -1
- package/guides/admin-plugins.md +206 -6
- package/guides/api-routes.md +159 -215
- package/guides/authorization.md +103 -114
- package/guides/backend-answered-pages.md +301 -252
- package/guides/bap-vs-inertia.md +67 -25
- package/guides/blueprints.md +300 -169
- package/guides/bun.md +42 -25
- package/guides/caching.md +46 -49
- package/guides/coming-from-inertia.md +2 -2
- package/guides/commands.md +251 -200
- package/guides/connection.md +50 -54
- package/guides/content-security-policy.md +133 -84
- package/guides/domains.md +190 -149
- package/guides/edge-caching.md +242 -268
- package/guides/emails.md +96 -45
- package/guides/errors.md +116 -137
- package/guides/feature-flags.md +100 -30
- package/guides/file-uploads.md +101 -26
- package/guides/fonts.md +139 -110
- package/guides/forms.md +520 -542
- package/guides/images.md +87 -28
- package/guides/index.json +13 -33
- package/guides/instrumentation.md +134 -95
- package/guides/isr.md +3 -3
- package/guides/live-data-in-production.md +695 -0
- package/guides/live-data.md +170 -839
- package/guides/mcp.md +83 -59
- package/guides/metadata.md +124 -179
- package/guides/navigation.md +118 -147
- package/guides/no-javascript.md +49 -57
- package/guides/offline.md +118 -153
- package/guides/openapi.md +100 -35
- package/guides/pages.md +160 -50
- package/guides/ppr.md +178 -256
- package/guides/pwa.md +251 -218
- package/guides/queries.md +171 -300
- package/guides/react-compiler.md +90 -50
- package/guides/redirects.md +141 -177
- package/guides/response-headers.md +76 -74
- package/guides/route-interception.md +112 -111
- package/guides/routing.md +216 -322
- package/guides/sections.md +63 -66
- package/guides/seo-files.md +127 -65
- package/guides/server-actions.md +285 -357
- package/guides/static-generation.md +131 -199
- package/guides/testing.md +269 -147
- package/guides/third-party-scripts.md +94 -47
- package/guides/typed-routes.md +115 -113
- package/guides/url-validation.md +113 -61
- package/guides/validation.md +53 -62
- package/guides/view-transitions.md +159 -132
- package/guides/where-it-runs.md +226 -162
- package/package.json +2 -2
- package/guides/admin.md +0 -520
- package/guides/deployment.md +0 -598
- package/guides/go.md +0 -539
- package/guides/laravel.md +0 -787
- package/guides/your-own-backend.md +0 -602
package/guides/bap-vs-inertia.md
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
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
|
-
##
|
|
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
|
-
##
|
|
75
|
+
## When to choose a BAP
|
|
40
76
|
|
|
41
|
-
- A slow part of a page
|
|
42
|
-
|
|
43
|
-
- Some pages are the same for everyone
|
|
44
|
-
should be served from disk or a CDN
|
|
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
|
|
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
|
|
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
|
|
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
|
|
58
|
-
[two processes](/hosts/laravel
|
|
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
|
|
65
|
-
|
|
66
|
-
|
|
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).
|