PrismaClient is currently incompatible with this browser environment and has been optimized for use in an unknown browser when performing updates

While attempting to update a single field in my database using server-actions and tanstackQuery, I encountered the following error message:

Error: PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in unknown). If this is unexpected, please open an issue: at Object.get (index-browser.js:203:15) at getDataById (get-all-apointment.ts:55:27) at approvedStatus (update-status.ts:11:45) at Object.mutationFn (admin-column.tsx:140:62) at Object.fn (mutation.js:72:29) at run (retryer.js:92:31) at Object.start (retryer.js:133:9) at Mutation.execute (mutation.js:107:40)

To address this issue, I created a server action and utilized tanstack query to execute it. However, upon clicking the approved button, the aforementioned error occurred.

The affected field in my column is as follows:


export type Events = {
  id: string;
  title: string;
  email: string;
  // Other fields...
};

export const columns: ColumnDef<Events>[] = [
/* Column definitions... */
];

Below are the details of my server-action code:

export const approvedStatus = async (id:string) => {
    try {
        const isExisting = await getDataById(id)
        if(!isExisting) return {error: "Data not existing"}

        await db.appoinmentSchedule.update({
            where: {
                id: id
            },
            data: {
                status: 'approved'
            }
        })

        return {succcess: "Event has successuffly updated!"}
    } catch (error) {
        console.log(error)
        throw error
   
    }
}

Answer №1

Prisma should only be used as a server-side solution and not in browser or client-facing pages.

To ensure Prisma is not mistakenly used in the client-facing bundle, make sure to include 'use server' at the top of files that reference Prisma. Additionally, for client-facing pages, include 'use client' to properly differentiate them.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Experience the dynamic live preview feature of Sanity integrated with NextJS 13

I am facing an issue with checking if preview mode is activated on my website. While following a YouTube tutorial, I realized that the instructions may be outdated with the latest NextJS update. This was the code snippet I was originally working with to ...

Sending selected IDs from the JSON data

In my project, there is a JSON file named "workers" which contains information about all the workers. I have created a select component to display the names of the workers like this: https://i.sstatic.net/0Glyf.png Currently, I am selecting some workers ...

Creating a new user account in STRAPI while logged in with Google

Hello, I am currently working on a login and register page. The frontend of my project is built with Nextjs (in the app directory) and the backend is powered by STRAPI (a REST API). I am attempting to implement Nextauth with Google provider to enable user ...

Searching for a MYSQL query to identify records with empty fields

In my database, there is data presented in the following example. I am aiming to select the row that is highlighted in red. Despite trying the query below, it does not fetch the specific row I need. Any assistance on this matter would be greatly appreciate ...

The Markdown formatting tool isn't displaying code snippets and tables properly

Markdown for Beginners --- title: 'Getting Started with Markdown' date: 'April 1, 2022' excerpt: 'An introduction to Markdown syntax' cover_image: '/images/posts/start-markdown.png' --- # Introduction to Markdown M ...

Exporting a module from a TypeScript definition file allows for seamless sharing

I am in the process of developing a definition file for the Vogels library, which serves as a wrapper for the AWS SDK and includes a property that exports the entire AWS SDK. declare module "vogels" { import AWS = require('aws-sdk'); export ...

Increase the value of a MySQL field upon the execution of a function

Looking to enhance the numerical value in a new table (refer to image below) each time a specific PHP function is called. Can someone provide the PHP code for this task? ...

Creating a Dynamic Table with Angular 6 - Automating the Population of Content Values

I have a task of populating a table with data from a JSON file. Take a look at the following code snippet: <table> <thead> <tr> <th *ngFor="let datakeys of listData[0] | keys">{{ datakeys }}</th> </tr> < ...

The Ion-icon fails to appear when it is passed as a prop to a different component

On my Dashboard Page, I have a component called <DashHome /> that I'm rendering. I passed in an array of objects containing icons as props, but for some reason, the icons are not getting rendered on the page. However, when I used console.log() t ...

Error: Type '() => () => Promise<void>' is not compatible with type 'EffectCallback'

Here is the code that I'm currently working with: useEffect(() => { document.querySelector('body').style['background-color'] = 'rgba(173, 232, 244,0.2)'; window.$crisp.push(['do', 'ch ...

Is there a way to turn off the pinch-to-zoom trackpad gesture or disable the Ctrl+wheel zoom function on a webpage

Take a look at this example - While zooming in on the image by pressing ctrl + scroll, the image zooms but the page itself does not scale. Only the image is affected by the zoom. I am attempting to replicate this functionality on my Next.js page. I have ...

Setting an expiry date for Firestore documents

Is it feasible to set a future date and time in a firestore document and trigger a function when that deadline is reached? Let's say, today I create a document and specify a date for the published field to be set to false fifteen days later. Can this ...

Issue: The module '@nx/nx-linux-x64-gnu' is not found and cannot be located

I'm encountering issues when trying to run the build of my Angular project with NX in GitHub Actions CI. The process fails and displays errors like: npm ERR! code 1 npm ERR! path /runner/_work/myapp/node_modules/nx npm ERR! command failed npm ERR! c ...

Is it possible to confirm the authenticity of a hashed secret without having knowledge of the salt used

My method of storing API-Keys involves hashing and saving them in a database. ... async function createToken(userId:number) { ... const salt=await bcrypt.genSalt(15) const hash=await bcrypt.hash(token, salt) await db.store({userId,hash}) } ...

Ways to separate handleSubmit() functions in React Hooks Form to prevent them from intermingling when nested within each other

I recently integrated React Hook Form into my Next JS App for handling forms. In my setup, I have two form components named FormA and FormB. However, I encountered an issue where triggering the handleSubmit() function for FormB also triggered the handleSub ...

Having trouble establishing a connection to MongoDB Compass using the specified connection string

I've set up a cluster and now I'd like to connect to it using MongoDB Compass. When I try to connect via Connect -> I have MongoDB Compass, I receive the connection string below: mongodb+srv://myname:<password>@myname.nauqp.mongodb.net/ ...

automated refreshing in Next.js

Is anyone else experiencing issues with auto refresh not working in my Next.js app? Every time I make a change to the code, I have to shut down and restart the app to see the updates. Does anyone know of any solutions for this issue? ...

Angular HttpClient Catch Return Value

In my quest to develop a universal service for retrieving settings from the server, I've encountered an issue. When errors arise, I want to intercept them and provide a default value (I have a predetermined configuration that should be utilized when e ...

Tips for passing the same value to two components using vuejs $emit

Can someone help with typing in Main, where the value can also be Test World? You can view a sample here >>> Sample The issue I'm facing is that when a user adds an item to the cart, the cart shows one more than it should. I've tried t ...

The node command line does not recognize the term 'require'

My Typescript project was compiling and running smoothly until recently when I started encountering the error ReferenceError: require is not defined every time I try to run node. I am uncertain whether this issue stems from Typescript, as even when I ru ...