release: WRNexusJS 0.8.0
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { CreateUserSchema } from "../schemas/create-user";
|
||||
|
||||
page ServerActions {
|
||||
seo {
|
||||
title = "Typed server actions"
|
||||
description = "Schema validation, CSRF, invalidation and progressive enhancement"
|
||||
}
|
||||
|
||||
action createUser using CreateUserSchema {
|
||||
invalidate("users")
|
||||
return { id: crypto.randomUUID(), name: input.name, email: input.email }
|
||||
}
|
||||
|
||||
view {
|
||||
<main>
|
||||
<h1>Typed server actions</h1>
|
||||
<p>The form works with or without JavaScript.</p>
|
||||
<form @submit="createUser">
|
||||
<label for="action-name">Name</label>
|
||||
<input id="action-name" name="name" autocomplete="name" required />
|
||||
<label for="action-email">Email</label>
|
||||
<input id="action-email" name="email" type="email" autocomplete="email" required />
|
||||
<button type="submit">Create user</button>
|
||||
</form>
|
||||
</main>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user