Skip to content

Commit 529b062

Browse files
Update 'use server' directive explanation (#1393)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 8e34da4 commit 529b062

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/routes/solid-start/reference/server/use-server.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,24 @@ description: >-
1717
Handle database operations, API calls, and secure logic on the server.
1818
---
1919

20-
`"use server"` will enable functions that only run on the server.
20+
`"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.
2121

2222
```tsx
23+
// Function-level
2324
const logHello = async (message: string) => {
2425
"use server";
2526
console.log(message);
2627
};
2728
```
29+
Or when using at the top of a file.
30+
```tsx
31+
// File-level
32+
"use server";
33+
34+
const logHello = async (message: string) => {
35+
console.log(message);
36+
};
37+
```
2838

2939
**Note:** `"use server"` functions must be marked async or return a promise.
3040

0 commit comments

Comments
 (0)