79757265

Date: 2025-09-06 01:02:47
Score: 2.5
Natty:
Report link

Why not access the data directly? If you are using NextJS as a backend..

Or if it's a client component:

actions.ts:

'use server'
import { db } from '@/lib/db' // Your database client
 
export async function fetchUsers() {
  const users = await db.user.findMany()
  return users
}

component.ts:

'use client'
import { fetchUsers } from '../actions'
 
export default function MyButton() {
  return <button onClick={() => fetchUsers()}>Fetch Users</button>
}

https://nextjs.org/docs/app/api-reference/directives/use-server#using-server-functions-in-a-client-component

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): Why not
  • Low reputation (1):
Posted by: JGabT