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
⨯ ReferenceError: Cannot access 'isBrowser' before initialization
at Module.isBrowser
...
page: '/api/audio/text-to-speech'
}
POST /api/audio/text-to-speech 500 in 50ms
Steps to reproduce
Create a Next.js 15 App router codebase
create an api route
in the same file add const deepgram = createClient(process.env.DEEPGRAM_API_KEY);
call the route
error will be thrown in the app console
Expected behavior
To just be able to use the sdk in an api route
Please tell us about your environment
We want to make sure the problem isn't specific to your operating system or programming language.
Operating System/Version: macOS
Language: TypeScript
Browser: Chrome
Next.js: 15.0.1
@deepgram/sdk: 3.9.0
Other information
This is the stack trace:
⨯ ReferenceError: Cannot access 'isBrowser' before initialization
at Module.isBrowser (/Users/claudio/Dev/web/cuecard/.next/server/chunks/node_modules_@deepgram_sdk_dist_module_6533bc._.js:147:23)
at [project]/node_modules/@deepgram/sdk/dist/module/lib/constants.js [app-route] (ecmascript) (/Users/claudio/Dev/web/cuecard/.next/server/chunks/node_modules_@deepgram_sdk_dist_module_6533bc._.js:99:211)
at instantiateModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:589:23)
at getOrInstantiateModuleFromParent (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:644:12)
at esmImport (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:132:20)
at [project]/node_modules/@deepgram/sdk/dist/module/lib/helpers.js [app-route] (ecmascript) (/Users/claudio/Dev/web/cuecard/.next/server/chunks/node_modules_@deepgram_sdk_dist_module_6533bc._.js:160:177)
at instantiateModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:589:23)
at getOrInstantiateModuleFromParent (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:644:12)
at esmImport (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:132:20)
at [project]/node_modules/@deepgram/sdk/dist/module/packages/ListenRestClient.js [app-route] (ecmascript) (/Users/claudio/Dev/web/cuecard/.next/server/chunks/node_modules_@deepgram_sdk_dist_module_6533bc._.js:676:175)
at instantiateModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:589:23)
at getOrInstantiateModuleFromParent (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:644:12)
at esmImport (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:132:20)
at [project]/node_modules/@deepgram/sdk/dist/module/packages/ListenClient.js [app-route] (ecmascript) (/Users/claudio/Dev/web/cuecard/.next/server/chunks/node_modules_@deepgram_sdk_dist_module_6533bc._.js:1269:189)
at instantiateModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:589:23)
at getOrInstantiateModuleFromParent (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:644:12)
at esmImport (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:132:20)
at [project]/node_modules/@deepgram/sdk/dist/module/DeepgramClient.js [app-route] (ecmascript) (/Users/claudio/Dev/web/cuecard/.next/server/chunks/node_modules_@deepgram_sdk_dist_module_6533bc._.js:2909:185)
at instantiateModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:589:23)
at getOrInstantiateModuleFromParent (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:644:12)
at esmImport (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:132:20)
at [project]/node_modules/@deepgram/sdk/dist/module/index.js [app-route] (ecmascript) <locals> (/Users/claudio/Dev/web/cuecard/.next/server/chunks/node_modules_@deepgram_sdk_dist_module_6533bc._.js:3030:175)
at instantiateModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:589:23)
at getOrInstantiateModuleFromParent (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:644:12)
at esmImport (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:132:20)
at [project]/libs/deepgram/speech.ts [app-route] (ecmascript) (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[root of the server]__c97bc6._.js:107:182)
at instantiateModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:589:23)
at getOrInstantiateModuleFromParent (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:644:12)
at esmImport (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:132:20)
at [project]/app/api/audio/text-to-speech/route.ts [app-route] (ecmascript) (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[root of the server]__c97bc6._.js:490:132)
at instantiateModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:589:23)
at getOrInstantiateModuleFromParent (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:644:12)
at esmImport (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:132:20)
at [project]/node_modules/next/dist/esm/build/templates/app-route.js { INNER_APP_ROUTE => "[project]/app/api/audio/text-to-speech/route.ts [app-route] (ecmascript)" } [app-route] (ecmascript) (/Users/claudio/Dev/web/cuecard/.next/server/chunks/_5829b8._.js:47:158)
at instantiateModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:589:23)
at instantiateRuntimeModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:652:12)
at Object.getOrInstantiateRuntimeModule (/Users/claudio/Dev/web/cuecard/.next/server/chunks/[turbopack]_runtime.js:668:12)
at Object.<anonymous> (/Users/claudio/Dev/web/cuecard/.next/server/app/api/audio/text-to-speech/route.js:13:26)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Module._load (node:internal/modules/cjs/loader:1104:12)
at Module.require (node:internal/modules/cjs/loader:1311:19)
at mod.require (/Users/claudio/Dev/web/cuecard/node_modules/next/dist/server/require-hook.js:65:28)
at require (node:internal/modules/helpers:179:18)
at requirePage (/Users/claudio/Dev/web/cuecard/node_modules/next/dist/server/require.js:103:84)
at loadComponentsImpl (/Users/claudio/Dev/web/cuecard/node_modules/next/dist/server/load-components.js:99:57)
at async DevServer.findPageComponentsImpl (/Users/claudio/Dev/web/cuecard/node_modules/next/dist/server/next-server.js:732:36)
at async DevServer.findPageComponents (/Users/claudio/Dev/web/cuecard/node_modules/next/dist/server/dev/next-dev-server.js:611:20)
at async DevServer.renderPageComponent (/Users/claudio/Dev/web/cuecard/node_modules/next/dist/server/base-server.js:2279:24) {
page: '/api/audio/text-to-speech'
}
POST /api/audio/text-to-speech 500 in 50ms
The text was updated successfully, but these errors were encountered:
What is the current behavior?
I am trying to use the JS sdk in a Next.js 15 App Router api route. So executed on the server.
I am instantiating Deepgram as per instructions here with
but I get the following error:
Steps to reproduce
const deepgram = createClient(process.env.DEEPGRAM_API_KEY);
Expected behavior
To just be able to use the sdk in an api route
Please tell us about your environment
Other information
This is the stack trace:
The text was updated successfully, but these errors were encountered: