Skip to content

Next.js example client does not build/throws OAuth error #32

@fry69

Description

@fry69

See:

$ cd examples/nextjs-example
$ npm install
[...]
$ npm run build

> nextjs-example@0.1.0 build
> next build

 ⚠ Warning: Next.js inferred your workspace root, but it may not be correct.
 We detected multiple lockfiles and selected the directory of /Users/fry/GitHub/OpenRouterTeam/typescript-sdk/package-lock.json as the root directory.
 To silence this warning, set `outputFileTracingRoot` in your Next.js config, or consider removing one of the lockfiles if it's not needed.
   See https://nextjs.org/docs/app/api-reference/config/next-config-js/output#caveats for more information.
 Detected additional lockfiles: 
   * /typescript-sdk/examples/nextjs-example/package-lock.json

   ▲ Next.js 15.5.4

   Creating an optimized production build ...
 ✓ Compiled successfully in 5.3s

./src/app/(app)/page.tsx
118:6  Warning: React Hook useEffect has missing dependencies: 'openRouter.oAuth' and 'setApiKey'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps
201:6  Warning: React Hook useEffect has a missing dependency: 'openRouter.oAuth'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules
Failed to compile.

./src/app/(app)/chat/_dialogs/not-connected.tsx:24:20
Type error: Property 'oAuth' does not exist on type 'OpenRouter'.

  22 |   const handleGotoOAuth = async () => {
  23 |     const { codeChallenge, codeVerifier } =
> 24 |       await client.oAuth.createSHA256CodeChallenge();
     |                    ^
  25 |
  26 |     const url = await client.oAuth.createAuthorizationUrl({
  27 |       codeChallenge,
Next.js build worker exited with code: 1 and signal: null

Same error can be seen in the browser when running:

$ npm run dev

The demo chat app is then obviously stuck on "generating OAuth URL".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions