@rsc-kit/mcp 0.32.0 → 0.34.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 +56 -11
- package/dist/recipes.js.map +1 -1
- package/guides/domains.md +100 -16
- 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
|
},
|
|
@@ -1603,11 +1621,15 @@ Full guide: read_guide({ slug: 'seo-files' }).`,
|
|
|
1603
1621
|
topic: 'domains',
|
|
1604
1622
|
summary: 'Subdomains and custom domains as route segments - admin.example.com reaches app/admin, a tenant host binds [domain], no rewrite',
|
|
1605
1623
|
body: `A request from a host that is not the site's own is matched with the host
|
|
1606
|
-
in FRONT of the path. The site's own hosts: the root layout's metadataBase
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1624
|
+
in FRONT of the path. The site's own hosts: the root layout's metadataBase
|
|
1625
|
+
(a literal - a computed one is not read for routing), www. of it, and
|
|
1626
|
+
rscKit({ hosts: [...] }). ONE of the two must name the site, or a subdomain
|
|
1627
|
+
is a foreign host whose segment is the whole name and is served by path,
|
|
1628
|
+
silently. With the address in the environment (Laravel's APP_URL), use
|
|
1629
|
+
hosts: loadEnv in vite.config.ts and hosts: [new URL(env.APP_URL).host] -
|
|
1630
|
+
that also names the local example.test under Herd, which a production
|
|
1631
|
+
metadataBase does not. hosts also takes a staging/internal name or a second
|
|
1632
|
+
brand domain. localhost and ips are always own.
|
|
1611
1633
|
|
|
1612
1634
|
example.com/admin -> /admin app/admin/page.tsx
|
|
1613
1635
|
admin.example.com/ -> /admin the same file (subdomain of an own host = its label)
|
|
@@ -1624,9 +1646,26 @@ stores one shell for all values, so a layout awaiting params above every
|
|
|
1624
1646
|
boundary fails the build: read them under <Suspense> in the layout, or list
|
|
1625
1647
|
the urls with generateStaticParams. A tenant check that should 404 goes in
|
|
1626
1648
|
[domain]/middleware.ts - its argument is the params, and notFound() there is
|
|
1627
|
-
a real 404. Otherwise [domain] is an ordinary dynamic segment: params.domain in every page/layout under it,
|
|
1628
|
-
|
|
1629
|
-
directory named for a host (app/admin/) wins over [domain].
|
|
1649
|
+
a real 404. Otherwise [domain] is an ordinary dynamic segment: params.domain in every page/layout under it, loading/error files
|
|
1650
|
+
as usual. A
|
|
1651
|
+
directory named for a host (app/admin/) wins over [domain]. A subdomain with no
|
|
1652
|
+
directory of its name (no app/merchant/) is served by path - the home page on
|
|
1653
|
+
merchant.example.com/ - and the dev server says "has no app/merchant/ - served
|
|
1654
|
+
by path" once per host. Add the directory; no config.
|
|
1655
|
+
|
|
1656
|
+
Links to another host: a typed href is the FOLDER path (/merchant/orders =
|
|
1657
|
+
example.com/merchant/orders - both addresses work, nothing redirects). To link
|
|
1658
|
+
to the subdomain or a tenant use hostUrl from '@rsc-kit/core/routes':
|
|
1659
|
+
hostUrl('merchant', '/orders') -> //merchant.example.com/orders (path typed
|
|
1660
|
+
as the pages under app/merchant, folder taken off); hostUrl(tenant.slug,
|
|
1661
|
+
'/settings') -> //testbrand.example.com/settings (host autocompletes to the
|
|
1662
|
+
top-level folders but takes any string; path typed by the tenant tree);
|
|
1663
|
+
hostUrl('acme.com', '/settings') -> //acme.com/settings (a dot = whole
|
|
1664
|
+
domain); hostUrl('/pricing') -> //example.com/pricing (back to the site from
|
|
1665
|
+
a subdomain). The site's host is the first rscKit({ hosts }) entry, port
|
|
1666
|
+
kept; with none named a folder's url is its path. Same string on server and
|
|
1667
|
+
browser; works in <Link>, visit() and redirect(). Do NOT build
|
|
1668
|
+
\`//\${slug}.\${host}\` by hand or read the request host for links.
|
|
1630
1669
|
|
|
1631
1670
|
\`\`\`tsx
|
|
1632
1671
|
// src/app/[domain]/layout.tsx
|
|
@@ -1769,8 +1808,10 @@ GLOBAL the build declares in .rsc-kit/rsc-env.d.ts - never import it. Have
|
|
|
1769
1808
|
Vite write the manifest so it cannot go stale:
|
|
1770
1809
|
rscKit({ hostManifest: { command: ['go', 'run', '.', '-manifest', '../rsc-host.json'], cwd: 'backend', watch: ['backend'] } })
|
|
1771
1810
|
(watch: rerun when the backend's source changes under dev, so new functions are typed
|
|
1772
|
-
without a restart).
|
|
1773
|
-
|
|
1811
|
+
without a restart). rsc-host.json is rewritten every dev start and build, so it
|
|
1812
|
+
is gitignored (init and create-rsc-kit add it); a CI typecheck before the build writes it first
|
|
1813
|
+
(php artisan rsc:host-manifest). Committed rsc-host.json/types anyway? CI:
|
|
1814
|
+
rsc-kit-typegen --check fails when they are stale.
|
|
1774
1815
|
(Go: reg.WriteManifest(path); Laravel: php artisan rsc:host-manifest).
|
|
1775
1816
|
Go TYPED functions - prefer these: reg.Handle("Orders.recent", func(ctx context.Context, limit int) ([]Order, error) {...})
|
|
1776
1817
|
and reg.HandleAction(jsName, name, fn). Any positional params (structs, slices,
|
|
@@ -1787,6 +1828,10 @@ A backend FAILURE in development carries its trace: the thrown error's cause is
|
|
|
1787
1828
|
"Backend <Type>" with the PHP/Go frames, and the stack says "Caused in the backend
|
|
1788
1829
|
by ..." - read that before guessing (Laravel: app.debug; Go: CallbackHandler.Debug
|
|
1789
1830
|
or RSC_DEBUG=1). Never in production.
|
|
1831
|
+
A server ACTION that fails in development opens Vite's error overlay on the
|
|
1832
|
+
page: the backend's exception as the heading, the app's own file:line (e.g.
|
|
1833
|
+
app/Rsc/Actions/Notification.php:20) as its file, dependency frames counted.
|
|
1834
|
+
Production answers a bare 500. Fix the line it names; the overlay is not a bug.
|
|
1790
1835
|
A failed rpc() in a server component: catch and check
|
|
1791
1836
|
error instanceof ServerAuthenticationError (401) / ServerAuthorizationError (403)
|
|
1792
1837
|
from '@rsc-kit/core/errors'; rethrow anything else.
|