X
Xata16mo ago
teri

Error in Next.js app with inserting a record

Why is the error persisting?
Uncaught Error: You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error.
Uncaught Error: You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error.
7 Replies
Dave Snider
Dave Snider16mo ago
You need to run your code in app/page.ts or app/api/route.ts rather than something like component/component.ts. Basically the code needs to be run on the server, not the client
Dave Snider
Dave Snider16mo ago
If you check the Next JS starter, it will show you the proper way to make these calls https://xata.io/docs/getting-started/nextjs
Get started with Next.js and Xata
Get started with Next.js and Xata
teri
teriOP16mo ago
Let me try your suggestion @Enemykite
Dave Snider
Dave Snider16mo ago
The sample gallery app is also a good place to check. You'll see that xata is only used server side, in the app folder (which are server side), not the components (which are client side). https://github.com/xataio/sample-nextjs-chakra-gallery-app
GitHub
GitHub - xataio/sample-nextjs-chakra-gallery-app: Gallery applicati...
Gallery application built with Xata, Next.js and Chakra UI - GitHub - xataio/sample-nextjs-chakra-gallery-app: Gallery application built with Xata, Next.js and Chakra UI
teri
teriOP16mo ago
I used Vite for Next.js boilerplate. I need help
Dave Snider
Dave Snider16mo ago
hey @teri. what do you need help with. i don't have access to your code so you'll need to give me some details about where you're running into trouble
teri
teriOP16mo ago
I have fixed it from the previous error message I had in this channel.

Did you find this page helpful?