Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit 7da69b6

Browse files
committed
Add some actions
1 parent 4b23dcc commit 7da69b6

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/routes/+page.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
<h1>Welcome to SvelteKit</h1>
22
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
3+
4+
<form method="POST" action="/auth?/login">
5+
<button>Login</button>
6+
</form>
7+
8+
<form method="POST" action="/auth?/logout">
9+
<button>Logout</button>
10+
</form>

src/routes/auth/+page.server.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { Actions } from './$types';
2+
3+
export const actions = {
4+
login: async (event) => {
5+
return {action: 'login'};
6+
},
7+
logout: async (event) => {
8+
return {action: 'logout'};
9+
},
10+
} satisfies Actions;

src/routes/auth/+page.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script lang="ts">
2+
import type { ActionData } from './$types';
3+
4+
5+
export let form: ActionData;
6+
</script>
7+
8+
<div>Form action: {form?.action}</div>

0 commit comments

Comments
 (0)