feat: Next.js Pages Router support#393
Open
andreas-karlsson wants to merge 3 commits intomainfrom
Open
Conversation
nicklasl
reviewed
May 5, 2026
nicklasl
reviewed
May 5, 2026
nicklasl
reviewed
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds three subexports under
./pages-router/*for the Next.js Pages Router, parallel to the existingreact-server/react-clientpair for App Router:pages-router/server—withConfidence(config, gssp?)HOC that resolves the flag bundle ingetServerSideProps(no exposure) and merges it intopageProps. Plus a low-levelresolveConfidencehelper.pages-router/client—<ConfidencePagesProvider>for_app.tsx. The existinguseFlag/useFlagDetailsfromreact-clientwork unchanged.pages-router/api—applyHandler({ providerName? }?)factory for the/api/confidence/applyPOST route the client uses to log exposure.The resolve token is sealed with AES-256-GCM (key from
CONFIDENCE_TOKEN_KEYenv var) before reaching the client, since Pages Router has no encrypted-closure equivalent to App Router server actions. The apply route opens it server-side.README-REACT.mdgets a new "Next.js Pages Router" section. The App Router quick-start was also moved toinstrumentation.tssince that's router-agnostic and avoids the build-time side-effect issue with top-level-await setup files.Test plan
yarn typecheckcleanyarn test— 7 token tests + 6 apply-handler tests passyarn buildemitsdist/pages-router/{server,client,api}.{js,d.ts}react-server/react-clientbuilds unchanged🤖 Generated with Claude Code