Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
73aefb3
docs: add v2 SDK pages with linked legacy v1 archive
roncohen Nov 15, 2026
3d3bb13
fix: preserve SDK heading anchors in GitBook
roncohen Nov 15, 2026
bf6511e
fix: keep deep SDK method anchors addressable in GitBook
roncohen Nov 15, 2026
2bae2df
fix: preserve public type anchors alongside SDK member links
roncohen Nov 15, 2026
8976090
docs: make current SDK guides stand on their own
roncohen Nov 15, 2026
cbddc72
docs: remove reader-facing SDK provenance notices
roncohen Nov 16, 2026
bd9d10a
docs: identify SDK v2 in current page introductions
roncohen Nov 16, 2026
90b2a52
docs: plain-language pass over SDK guides and shared pages
roncohen Nov 16, 2026
00dd0b4
docs: simplify how SDK guides explain flag reads and defaults
roncohen Nov 16, 2026
3d3b61e
docs: separate Multivariate flags from Remote config
roncohen Nov 17, 2026
cba8cfc
docs: clarify Multivariate flags and remote config migration
roncohen Nov 17, 2026
ac7ff2d
docs: use a portable link to the SDK upgrade guide
roncohen Nov 17, 2026
42cf05d
docs: describe upcoming MCP-assisted remote config migration
roncohen Nov 17, 2026
c35d60b
docs: present MCP-assisted remote config migration as available
roncohen Nov 17, 2026
d36da38
docs: align SDK guide structure and tighten handbook wording
roncohen Nov 17, 2026
688a485
docs: lead remote config migration with agent guidance
roncohen Nov 17, 2026
e52208b
docs: restore numbered get-started steps in SDK guides
roncohen Nov 17, 2026
1e0adfc
docs: check remote config usage before planning migration
roncohen Nov 17, 2026
22c806d
docs: show rolling SDK bootstrap migration
roncohen Nov 21, 2026
bebf94a
docs: avoid duplicate tracking during bootstrap migration
roncohen Nov 21, 2026
7d2f186
docs: make v1 the bootstrap-only client
roncohen Nov 21, 2026
44ffaf2
docs: require public-only SDKs for dual bootstrap
roncohen Nov 21, 2026
f4ecbe4
Merge importer foundation into draft docs without changing public con…
roncohen Nov 24, 2026
baeb200
docs: ask about older clients before planning an upgrade
roncohen Nov 24, 2026
912d084
docs: link upgrade prompts and surface uncertain configs
roncohen Nov 24, 2026
1f9c61a
docs: cover React Native in the SDK v2 upgrade guide
roncohen Nov 25, 2026
e6595f0
docs: make the rolling bootstrap link work in GitBook
roncohen Nov 25, 2026
74a2627
docs: keep bootstrap migration focused on protocol compatibility
roncohen Nov 27, 2026
22deb09
docs: clarify React Native flag type generation
roncohen Nov 27, 2026
e4f9007
docs: clarify v2 flag values and migration behavior
roncohen Nov 27, 2026
8b6a740
docs: prefer app-shaped values in Remote config migrations
roncohen Nov 27, 2026
035c3b7
docs: tell the migration agent to update config readers
roncohen Nov 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .generated/sdk-docs/browser-sdk/v1.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .generated/sdk-docs/browser-sdk/v2.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .generated/sdk-docs/node-sdk/v1.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .generated/sdk-docs/node-sdk/v2.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .generated/sdk-docs/react-native-sdk/v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .generated/sdk-docs/react-sdk/v1.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .generated/sdk-docs/react-sdk/v2.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .generated/sdk-docs/vue-sdk/v1.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .generated/sdk-docs/vue-sdk/v2.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated SDK copies; authoritative READMEs/comments live in reflagcom/javascript.
sdk/** linguist-generated=true
supported-languages/browser-sdk/** linguist-generated=true
supported-languages/react-sdk/** linguist-generated=true
supported-languages/vue-sdk/** linguist-generated=true
supported-languages/node-sdk/** linguist-generated=true
supported-languages/react-native-sdk/** linguist-generated=true
legacy/v1/*-sdk/** linguist-generated=true
.generated/** linguist-generated=true
16 changes: 16 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ Reflag is built to work at the company/organization level right out of the box,

This repository syncs the documentation to [docs.reflag.com](https://docs.reflag.com). For SDK docs, please go to the [javascript repository](https://github.com/reflagcom/javascript) repository.

## SDK documentation ownership

SDK READMEs and source comments are maintained in `reflagcom/javascript`. Current Browser/React/Vue/Node pages are generated into `supported-languages/`; protocol-v1 pages live in `legacy/v1/`. Do not hand-edit their generated bodies. Source/version and file hashes are recorded in `.generated/sdk-docs/`. Current pages assume a new installation. The importer adds one short SDK v2 scope line after the introduction and a legacy/upgrade link at the end; these site-only notes are reapplied on every source sync. Prerelease availability and major-pinned upgrade commands belong in the migration guide. Keep release-readiness status in PRs and the migration guide, not repeated page banners.

Generate one SDK from an explicitly selected, clean source checkout after building declarations and running its canonical `docs.sh`:

```sh
node .github/scripts/sdk-docs.mjs import --source /path/to/built/javascript --package react-sdk
node .github/scripts/check-sdk-docs.mjs
node --test .github/scripts/sdk-docs.test.mjs
```

The importer derives the destination from the package major, preserves historical SDK aliases, and never deletes a tree or overwrites navigation, migration guidance or GitBook settings. Release automation uses the `release` subcommand with an exact tagged-source plan; prereleases do not promote stable documentation automatically. The SDK documentation workflow rebuilds the source commits listed in the manifests and checks representative examples against matching declarations.

This is ordinary page-based navigation. No GitBook variants or additional published spaces are required.

## Quick links

- Ready to get started? [Follow the guide](https://docs.reflag.com/)
Expand Down
137 changes: 137 additions & 0 deletions .github/scripts/check-sdk-examples.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
const assert = require("node:assert/strict");
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
const { createRequire } = require("node:module");

const [frameworkRoot, nodeRoot, legacyRoot] = process.argv
.slice(2)
.map((root) => path.resolve(root));
assert(
frameworkRoot && nodeRoot && legacyRoot,
"Pass built framework-v2, node-v2 and v1 source directories",
);
const root = path.resolve(__dirname, "../..");
const sdkRequire = createRequire(path.join(frameworkRoot, "package.json"));
const ts = sdkRequire("typescript");
const reactTypes = path.dirname(sdkRequire.resolve("@types/react/package.json"));
const nodeTypes = path.dirname(sdkRequire.resolve("@types/node/package.json"));
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "reflag-sdk-doc-examples-"));
let snippets = 0;
function declaration(base, name) {
const dir = path.join(base, "packages", name);
const pkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
const file = path.join(dir, pkg.types);
assert(fs.existsSync(file), `Build declarations first: ${file}`);
return file;
}
function blocks(file) {
return [
...fs
.readFileSync(path.join(root, file), "utf8")
.matchAll(/```(?:tsx|jsx|typescript|ts)\r?\n([\s\S]*?)```/g),
].map((match) => match[1]);
}
function compile(label, code, legacy = false, extra = {}) {
const dir = path.join(temp, `${snippets++}`);
fs.mkdirSync(dir);
const file = path.join(dir, "example.tsx");
const globals = path.join(dir, "globals.d.ts");
fs.writeFileSync(file, code);
fs.writeFileSync(
globals,
`declare module "your-component-library" { export const Spinner: import("react").FC<import("react").HTMLAttributes<HTMLSpanElement>>; }\n`,
);
const paths = {
"@reflag/react-sdk": [declaration(legacy ? legacyRoot : frameworkRoot, "react-sdk")],
"@reflag/browser-sdk": [declaration(legacy ? legacyRoot : frameworkRoot, "browser-sdk")],
"@reflag/node-sdk": [declaration(legacy ? legacyRoot : nodeRoot, "node-sdk")],
"@reflag/node-sdk-v1": [declaration(legacyRoot, "node-sdk")],
"@reflag/vue-sdk": [declaration(legacy ? legacyRoot : frameworkRoot, "vue-sdk")],
react: [path.join(reactTypes, "index.d.ts")],
"react/jsx-runtime": [path.join(reactTypes, "jsx-runtime.d.ts")],
next: [path.join(path.dirname(sdkRequire.resolve("next/package.json")), "index.d.ts")],
};
for (const [name, content] of Object.entries(extra)) {
const target = path.join(dir, `${name.replaceAll(/[^\w]/g, "-")}.tsx`);
fs.writeFileSync(target, content);
paths[name] = [target];
}
const ambient = label.startsWith("Next.js") ? [path.join(reactTypes, "canary.d.ts")] : [];
const program = ts.createProgram(
[file, globals, path.join(nodeTypes, "index.d.ts"), ...ambient],
{
target: ts.ScriptTarget.ES2022,
module: ts.ModuleKind.ESNext,
moduleResolution: ts.ModuleResolutionKind.Bundler,
jsx: ts.JsxEmit.ReactJSX,
strict: true,
noEmit: true,
skipLibCheck: true,
types: [],
baseUrl: frameworkRoot,
paths,
},
);
const diagnostics = ts.getPreEmitDiagnostics(program);
if (diagnostics.length)
throw new Error(
`${label}:\n${ts.formatDiagnosticsWithColorAndContext(diagnostics, { getCanonicalFileName: (file) => file, getCurrentDirectory: () => root, getNewLine: () => "\n" })}`,
);
}
try {
for (const file of [
"product-handbook/multivariate-flags.md",
"product-handbook/anonymous-users.md",
"product-handbook/feature-clean-up-and-archival-beta/ai-code-clean-up-beta.md",
"product-handbook/type-safety.md",
"product-handbook/launch-monitor/README.md",
"product-handbook/launch-monitor/give-feedback-button.md",
"guides/toggle-toolbar-with-a-flag.md",
"guides/use-reflag-in-your-cli.md",
])
blocks(file).forEach((code, index) => compile(`${file} #${index + 1}`, code));
blocks("product-handbook/feature-entitlements/README.md")
.slice(0, 2)
.forEach((code, index) => compile(`Entitlements #${index + 1}`, code));
compile("Opt-in loading and membership", blocks("guides/self-opt-in.md")[0]);
const gettingStarted = blocks("README.md");
compile("Getting started: Boolean", gettingStarted[0]);
compile("Getting started: feedback", gettingStarted[2]);
const next = blocks("supported-languages/next.js.md");
compile("Next.js singleton", next[0]);
compile("Next.js server action", next[1], false, {
"@/app/reflag": next[0],
"@/app/auth":
'import type { Context } from "@reflag/node-sdk"; export async function getContext(): Promise<Context> { return {}; }',
});
compile("Next.js Pages router", next[2], false, {
"@/app/reflag": next[0],
"@/app/auth":
'import type { Context } from "@reflag/node-sdk"; export async function getContext(): Promise<Context> { return {}; }',
});
compile("Next.js client", next[3]);
const dualBootstrap = blocks("supported-languages/migrating-from-v1.md").find((code) =>
code.includes('from "@reflag/node-sdk-v1"'),
);
assert(dualBootstrap, "Missing side-by-side Node.js bootstrap example");
compile("Migration: side-by-side Node.js bootstrap", dualBootstrap);
compile(
"Vue v2 declaration guard",
`import { useFlag } from "@reflag/vue-sdk";\nconst enabled: boolean = useFlag("huddle").value;\nconst count: number = useFlag("settings", { maxItems: 10 }).value.maxItems;\n// @ts-expect-error Vue returns a ref of the direct value, not a flag wrapper.\nuseFlag("huddle").isEnabled;\n// @ts-expect-error Ref contents are not any.\nconst invalid: string = useFlag("settings", { maxItems: 10 }).value.maxItems;\n`,
);
compile(
"v1 declaration guard",
`import { useFlag } from "@reflag/react-sdk";\nconst enabled: boolean = useFlag("huddle").isEnabled;\n// @ts-expect-error Reject any-shaped declarations.\nconst invalid: number = useFlag("huddle").isEnabled;\n`,
true,
);
compile(
"v2 declaration guard",
`import { useFlag, useFlagSuspense } from "@reflag/react-sdk";\nimport { ReflagClient } from "@reflag/node-sdk";\nconst enabled: boolean = useFlag("huddle");\nconst count: number = useFlag("settings", { maxItems: 10 }).maxItems;\nconst suspended: boolean = useFlagSuspense("huddle");\n// @ts-expect-error No wrapper API in v2.\nuseFlag("huddle").isEnabled;\n// @ts-expect-error Inferred fields are not any.\nconst invalid: string = useFlag("settings", { maxItems: 10 }).maxItems;\nconst client = new ReflagClient();\nconst serverEnabled: boolean = client.getFlag({}, "huddle");\n// @ts-expect-error Node returns a value, not a wrapper.\nclient.getFlag({}, "huddle").isEnabled;\n`,
);
console.log(
`${snippets} documentation examples/declaration guards compiled with zero diagnostics.`,
);
} finally {
fs.rmSync(temp, { recursive: true, force: true });
}
48 changes: 48 additions & 0 deletions .github/scripts/sdk-docs-site.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import test from "node:test";
import { checkLinks, checkSDKDocs, root, sourceMatrix } from "./check-sdk-docs.mjs";

test("published-content cutover validates generated pages, version links and navigation", () => {
assert(checkSDKDocs().generatedPages >= 28);
});

test("handbook keeps Remote config as a short pointer to the full Multivariate flags guide", () => {
const summary = fs.readFileSync(path.join(root, "SUMMARY.md"), "utf8");
for (const file of ["remote-config.md", "multivariate-flags.md"])
assert(summary.includes(`(product-handbook/${file})`));
const remote = fs.readFileSync(path.join(root, "product-handbook/remote-config.md"), "utf8");
const paragraph = remote
.replace(/^---\n[\s\S]*?\n---\n/, "")
.replace(/^# Remote config\s*/m, "")
.trim();
assert.equal(paragraph.split(/\n\s*\n/).length, 1);
assert.match(paragraph, /\[Multivariate flag\]\(multivariate-flags\.md\)/);
assert(!paragraph.includes("```"));
const multivariate = fs.readFileSync(
path.join(root, "product-handbook/multivariate-flags.md"),
"utf8",
);
assert.match(multivariate, /^# Multivariate flags$/m);
assert(multivariate.includes("export function AssistantSettings()"));
assert(multivariate.includes("export function AssistantModel()"));
assert.match(
multivariate,
/^## Migrating from Remote config$[\s\S]*^### Using an AI agent$[\s\S]*^### Manual migration\n\n1\./m,
);
assert(multivariate.includes("[Reflag MCP](../api/mcp.md)"));
checkLinks(root, ["product-handbook/remote-config.md", "product-handbook/multivariate-flags.md"]);
});

test("cutover CI discovers exact source refs from manifests", () => {
const matrix = sourceMatrix();
assert(matrix.include.length > 0);
for (const row of matrix.include) {
assert(/^[a-f\d]{40}$/.test(row.ref));
assert.match(
row.packages,
/^(?:--package (?:browser-sdk|react-sdk|vue-sdk|node-sdk|react-native-sdk|management-sdk|cli)(?: |$))+$/,
);
}
});
Loading
Loading