#Server function and "internal" functions.

4 messages · Page 1 of 1 (latest)

high mango
#

Is there such a thing as internal functions? Something that can only be called from Tanstack start functions.

I've just created a system for sending notifications, which will only ever be consumed in server funcitons, so I'm wondering if there's a solution to ensure that sending notifications can only happen from server functions.

paper sigil
#

so I'm wondering if there's a solution to ensure that sending notifications can only happen from server functions.
Specifically "server functions" i believe no.

There is one for "executeable only on server side" though, serverOnly

import { serverOnly } from '@tanstack/react-start'

const thisCanOnlyBeExecutedOnServerSide = serverOnly(() => {
  // ... implementation
})

it will throw if called from client side

high mango
#

Hell yeah, thanks for that! Worked a treat

#

I was looking through the docs for server only, so maybe I just blind on that day