From e889987072f03f407eccf90ba3edd52660769fa6 Mon Sep 17 00:00:00 2001 From: KipZonderKop101 <80620930+KipzonderKop101@users.noreply.github.com> Date: Mon, 29 Dec 2025 17:43:40 +0100 Subject: [PATCH] Update 'use server' directive explanation Clarify the usage of 'use server' directive in SolidStart. Proposed as it's often misused, as you can see in the wild: https://github.com/orgs/supabase/discussions/12891 --- .../solid-start/reference/server/use-server.mdx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/routes/solid-start/reference/server/use-server.mdx b/src/routes/solid-start/reference/server/use-server.mdx index c19e3fbf03..5f8be72126 100644 --- a/src/routes/solid-start/reference/server/use-server.mdx +++ b/src/routes/solid-start/reference/server/use-server.mdx @@ -17,14 +17,24 @@ description: >- Handle database operations, API calls, and secure logic on the server. --- -`"use server"` will enable functions that only run on the server. +`"use server"` enables functions or files to be executed only on the server. Server functions allow client components to call code that is executed in the server context. ```tsx +// Function-level const logHello = async (message: string) => { "use server"; console.log(message); }; ``` +Or when using at the top of a file. +```tsx +// File-level +"use server"; + +const logHello = async (message: string) => { + console.log(message); +}; +``` **Note:** `"use server"` functions must be marked async or return a promise.