@rsc-kit/mcp 0.31.3 → 0.33.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 +42 -4
- package/dist/recipes.js.map +1 -1
- package/guides/content-security-policy.md +48 -1
- package/guides/domains.md +9 -0
- package/guides/go.md +3 -1
- package/guides/installation.md +9 -0
- package/guides/laravel.md +26 -0
- package/guides/metadata.md +6 -0
- package/guides/routing.md +6 -0
- package/guides/seo-files.md +6 -0
- package/guides/your-own-backend.md +9 -0
- package/package.json +2 -2
package/dist/recipes.js
CHANGED
|
@@ -188,6 +188,14 @@ project and writes false, and then a dialog or dropdown it adds has no
|
|
|
188
188
|
a bare \`shadcn init\`, set it by hand. \`import { cn } from "cn"\` in its
|
|
189
189
|
components is correct: cn is shadcn's own package (lib/utils re-exports it).
|
|
190
190
|
|
|
191
|
+
**components.json's tailwind.css must be a stylesheet the app loads**: the root
|
|
192
|
+
layout's styles.css or a file it @imports. shadcn writes the theme (colours,
|
|
193
|
+
.dark, @custom-variant dark) there. In a Laravel app resources/css/app.css is
|
|
194
|
+
loaded only by Blade's @vite, so a theme there is a theme nothing loads - no
|
|
195
|
+
colours, no dark mode: @import '../../css/app.css' from
|
|
196
|
+
resources/js/app/styles.css (rsc-kit init does), or move it into styles.css
|
|
197
|
+
and point components.json at it.
|
|
198
|
+
|
|
191
199
|
**shadcn/ui works as-is.** Input, Textarea, Button and Label are styled native
|
|
192
200
|
elements, so \`name\` does what it always does. Select, Checkbox, Switch and
|
|
193
201
|
RadioGroup are Radix underneath and render a hidden native control whenever
|
|
@@ -1299,6 +1307,9 @@ Full guide: read_guide({ slug: 'fonts' }).`,
|
|
|
1299
1307
|
body: `The app/ conventions are the same: layout, page, loading, error, not-found,
|
|
1300
1308
|
route.ts, [slug], [...path], (group), @slot, (.)intercept. "use client" and
|
|
1301
1309
|
"use server" are React's. Copy src/app first, fix imports second.
|
|
1310
|
+
A (group) adds nothing to the url, so two groups can hold the same page:
|
|
1311
|
+
(home)/page.tsx and (preview)/(home)/page.tsx are both / and stop the build
|
|
1312
|
+
with an error naming both. Give one a real directory: (preview)/home/page.tsx.
|
|
1302
1313
|
|
|
1303
1314
|
IMPORTS
|
|
1304
1315
|
next/link -> @rsc-kit/core/Link (href typed; search typed by the page's schema)
|
|
@@ -1393,7 +1404,11 @@ the browser from props a controller assembled; here the page is a server
|
|
|
1393
1404
|
component rendered in front of Laravel that reads by name with rpc().
|
|
1394
1405
|
Install: composer require rsc-kit/laravel && php artisan rsc:install
|
|
1395
1406
|
(runs rsc-kit init; one vite.config.ts, laravel-vite-plugin moved aside;
|
|
1396
|
-
route tree is resources/js/app).
|
|
1407
|
+
route tree is resources/js/app). In a terminal it asks: React Compiler,
|
|
1408
|
+
Tailwind, shadcn/ui, oxlint - never a validation library or typed env (Laravel
|
|
1409
|
+
has FormRequests and .env). composer require itself cannot ask: Composer runs
|
|
1410
|
+
no dependency's scripts. Unattended: --compiler=oxc --tailwind --shadcn --lint.
|
|
1411
|
+
See how_to backend for rpc(), attributes,
|
|
1397
1412
|
make:rsc-action and the manifest.
|
|
1398
1413
|
|
|
1399
1414
|
WHAT EACH PIECE BECOMES
|
|
@@ -1596,6 +1611,9 @@ A file as written beside the root layout is served at the root as it is:
|
|
|
1596
1611
|
robots.txt, sitemap.xml, sitemap-*.xml, llms.txt, llms-full.txt, humans.txt,
|
|
1597
1612
|
security.txt, ads.txt. A file and a function for the same url is a build
|
|
1598
1613
|
error. Do NOT put these in public/ and do NOT write a middleware.ts for them.
|
|
1614
|
+
A file of the same name already in public/ (Laravel ships public/robots.txt
|
|
1615
|
+
and an empty public/favicon.ico) is answered instead of the app's - dev start
|
|
1616
|
+
and the build warn "is answered at /robots.txt" - delete the public/ one.
|
|
1599
1617
|
|
|
1600
1618
|
Full guide: read_guide({ slug: 'seo-files' }).`,
|
|
1601
1619
|
},
|
|
@@ -1626,7 +1644,10 @@ the urls with generateStaticParams. A tenant check that should 404 goes in
|
|
|
1626
1644
|
[domain]/middleware.ts - its argument is the params, and notFound() there is
|
|
1627
1645
|
a real 404. Otherwise [domain] is an ordinary dynamic segment: params.domain in every page/layout under it, typed
|
|
1628
1646
|
route('/[domain]/settings', { domain }), loading/error files as usual. A
|
|
1629
|
-
directory named for a host (app/admin/) wins over [domain].
|
|
1647
|
+
directory named for a host (app/admin/) wins over [domain]. A subdomain with no
|
|
1648
|
+
directory of its name (no app/merchant/) is served by path - the home page on
|
|
1649
|
+
merchant.example.com/ - and the dev server says "has no app/merchant/ - served
|
|
1650
|
+
by path" once per host. Add the directory; no config.
|
|
1630
1651
|
|
|
1631
1652
|
\`\`\`tsx
|
|
1632
1653
|
// src/app/[domain]/layout.tsx
|
|
@@ -1708,6 +1729,17 @@ navigation is REFUSED - put CSS in a stylesheet and code in a module, or add
|
|
|
1708
1729
|
'unsafe-inline' to style-src. Keep style-src-attr 'unsafe-inline': React's
|
|
1709
1730
|
style={{...}} is an attribute, which no hash or nonce can allow.
|
|
1710
1731
|
|
|
1732
|
+
A LIBRARY THAT TAKES A NONCE (next-themes, an analytics snippet): pass it
|
|
1733
|
+
useNonce() from '@rsc-kit/core/useNonce', a client hook - wrap the provider in
|
|
1734
|
+
a 'use client' component and render that from the root layout:
|
|
1735
|
+
const nonce = useNonce(); <ThemeProvider nonce={nonce} ...>
|
|
1736
|
+
Never read a nonce on the server and pass it down as a prop: a navigation's
|
|
1737
|
+
payload has a different nonce from the document's. useNonce() is undefined on
|
|
1738
|
+
a page allowed by hash (stored, a shell's own HTML) - the library's inline
|
|
1739
|
+
script is hashed there and runs; a <style> it inserts after hydration runs only
|
|
1740
|
+
where the page has a nonce (next-themes' disableTransitionOnChange: drop it, or
|
|
1741
|
+
'unsafe-inline' in style-src, on a stored page with no holes).
|
|
1742
|
+
|
|
1711
1743
|
Everywhere: Node, Bun, Docker, Workers, functions. A static export carries a
|
|
1712
1744
|
<meta http-equiv="Content-Security-Policy"> per page (no frame-ancestors,
|
|
1713
1745
|
report-uri, report-to, sandbox or report-only in a meta). An edge gets each
|
|
@@ -1758,8 +1790,10 @@ GLOBAL the build declares in .rsc-kit/rsc-env.d.ts - never import it. Have
|
|
|
1758
1790
|
Vite write the manifest so it cannot go stale:
|
|
1759
1791
|
rscKit({ hostManifest: { command: ['go', 'run', '.', '-manifest', '../rsc-host.json'], cwd: 'backend', watch: ['backend'] } })
|
|
1760
1792
|
(watch: rerun when the backend's source changes under dev, so new functions are typed
|
|
1761
|
-
without a restart).
|
|
1762
|
-
|
|
1793
|
+
without a restart). rsc-host.json is rewritten every dev start and build, so it
|
|
1794
|
+
is gitignored (init and create-rsc-kit add it); a CI typecheck before the build writes it first
|
|
1795
|
+
(php artisan rsc:host-manifest). Committed rsc-host.json/types anyway? CI:
|
|
1796
|
+
rsc-kit-typegen --check fails when they are stale.
|
|
1763
1797
|
(Go: reg.WriteManifest(path); Laravel: php artisan rsc:host-manifest).
|
|
1764
1798
|
Go TYPED functions - prefer these: reg.Handle("Orders.recent", func(ctx context.Context, limit int) ([]Order, error) {...})
|
|
1765
1799
|
and reg.HandleAction(jsName, name, fn). Any positional params (structs, slices,
|
|
@@ -1776,6 +1810,10 @@ A backend FAILURE in development carries its trace: the thrown error's cause is
|
|
|
1776
1810
|
"Backend <Type>" with the PHP/Go frames, and the stack says "Caused in the backend
|
|
1777
1811
|
by ..." - read that before guessing (Laravel: app.debug; Go: CallbackHandler.Debug
|
|
1778
1812
|
or RSC_DEBUG=1). Never in production.
|
|
1813
|
+
A server ACTION that fails in development opens Vite's error overlay on the
|
|
1814
|
+
page: the backend's exception as the heading, the app's own file:line (e.g.
|
|
1815
|
+
app/Rsc/Actions/Notification.php:20) as its file, dependency frames counted.
|
|
1816
|
+
Production answers a bare 500. Fix the line it names; the overlay is not a bug.
|
|
1779
1817
|
A failed rpc() in a server component: catch and check
|
|
1780
1818
|
error instanceof ServerAuthenticationError (401) / ServerAuthorizationError (403)
|
|
1781
1819
|
from '@rsc-kit/core/errors'; rethrow anything else.
|