You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/docs/plugins/blog.mdx
+44-5Lines changed: 44 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -585,18 +585,18 @@ You can import the hooks from `"@btst/stack/plugins/blog/client/hooks"` to use i
585
585
586
586
## Server-side Data Access
587
587
588
-
The blog plugin exposes standalone getter functions for server-side and SSG use cases. These bypass the HTTP layer entirely and query the database directly.
588
+
The blog plugin exposes standalone getter and mutation functions for server-side use cases. These bypass the HTTP layer entirely and query the database directly — no authorization hooks are called, so the caller is responsible for any access-control checks.
589
589
590
590
### Two patterns
591
591
592
592
**Pattern 1 — via `stack().api` (recommended for runtime server code)**
593
593
594
-
After calling `stack()`, the returned object includes a fully-typed `api` namespace. Getters are pre-bound to the adapter:
594
+
After calling `stack()`, the returned object includes a fully-typed `api` namespace. Getters and mutations are pre-bound to the adapter:
595
595
596
596
```ts title="app/lib/stack.ts"
597
597
import { myStack } from"./stack"; // your stack() instance
598
598
599
-
//In a Server Component, generateStaticParams, etc.
599
+
//Getters — read-only
600
600
const result =awaitmyStack.api.blog.getAllPosts({ published: true });
**No authorization hooks are called** when using `stack().api.*` or direct imports. These functions hit the database directly. Always perform your own access-control checks before calling them from user-facing code.
645
+
</Callout>
646
+
624
647
### Available getters
625
648
626
649
| Function | Returns | Description |
@@ -637,6 +660,22 @@ export async function generateStaticParams() {
`route.loader()` makes HTTP requests to `apiBaseURL`, which silently fails during `next build` because no dev server is running. Use `prefetchForRoute()` instead — it reads directly from the database and pre-populates the React Query cache before rendering.
0 commit comments