@lunora/astro 1.0.0-alpha.8 → 1.0.0-alpha.9
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/README.md +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,6 +98,24 @@ const preloaded = await preloadQuery(client, api.messages.list, {});
|
|
|
98
98
|
<my-island data-preloaded={serializePreloaded(preloaded)}></my-island>
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
### Feature flags
|
|
102
|
+
|
|
103
|
+
`@lunora/astro` ships no flag hook — like every other surface, flags follow the same server/island split. Read `ctx.flags` server-side (a server endpoint, a function, or the same `.astro` frontmatter) and hand the resolved value to the island, or call `useFlag` inside the island itself via the adapter you hydrate with (`@lunora/react`, `@lunora/vue`, …). Requires [`@lunora/flags`](https://www.npmjs.com/package/@lunora/flags) wired in `lunora/flags.ts`.
|
|
104
|
+
|
|
105
|
+
```astro
|
|
106
|
+
---
|
|
107
|
+
// src/pages/index.astro — resolve the flag once, server-side
|
|
108
|
+
import { createServerClient, preloadQuery, preloadedQueryResult } from "@lunora/astro/server";
|
|
109
|
+
import { api } from "../lunora/_generated/api";
|
|
110
|
+
|
|
111
|
+
const client = createServerClient({ url: Astro.url.origin + "/_lunora/rpc" });
|
|
112
|
+
const preloaded = await preloadQuery(client, api.homepage.heroFlag, {}); // a query that returns ctx.flags.boolean(...)
|
|
113
|
+
const newHero = preloadedQueryResult(preloaded);
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
{newHero ? <NewHero client:load /> : <ClassicHero client:load />}
|
|
117
|
+
```
|
|
118
|
+
|
|
101
119
|
> This README covers the basics. For the full API, options, and guides, see the **[documentation](https://lunora.sh/docs/frameworks/bring-your-framework)**.
|
|
102
120
|
|
|
103
121
|
## Related
|