You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/routes/solid-router/concepts/actions.mdx
-36Lines changed: 0 additions & 36 deletions
Original file line number
Diff line number
Diff line change
@@ -109,42 +109,6 @@ export function MyComponent() {
109
109
}
110
110
```
111
111
112
-
## Server actions
113
-
114
-
Sometimes we need to make sure our action _only_ runs on the server. This is useful for:
115
-
116
-
- Accessing internal APIs.
117
-
- Proxying external APIs.
118
-
- To use server secrets.
119
-
- To reduce the response payload by postprocessing.
120
-
- To bypass CORS.
121
-
- Running code incompatible with browsers.
122
-
- Or even connecting directly to a database. (Take caution, opinions on if this is a good idea are mixed. You should consider separating your backend and frontend).
123
-
124
-
To do this, put a `"use server";` directive in your action function:
We strongly recommend with actions to "return" errors rather than throwing them. This can help with typing of submissions you'd use with `useSubmission`. This is important especially for handling progressive enhancement where no JS is present in the client so that we can use the error declaratively to render the updated page on the server.
0 commit comments