#How to call server function from client without the need of API

21 messages · Page 1 of 1 (latest)

mellow raftBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

sick saddle
#

not possible

junior pond
#

Use server actions

lapis walrus
#

amm

#

not possible or use server actions?

lapis walrus
#

because that is not what I am talking about

#

I am tolking about a server function insede a onClick handler function

sick saddle
lapis walrus
#

can I do something like this

#
import React from 'react'
import { handleClick } from '@/actoions/handleclick'

export default function Button() {
  return (
    <button onClick={async () => await handleClick()}>View stores nearby</button>
  )
}

#
'use server'

export const handleClick = ()=> {
    console.log('heLLo world')
}
sick saddle
#

this is because code will be directly running in the browser

lapis walrus
#

man, I restarted my server and now its working like its expected haha

#

sorry for the questio here

junior pond
junior pond
lapis walrus
#

yes, its server side, so my secrets will stay safe

#

ok tnx for the help