Skip to content

Instantly share code, notes, and snippets.

@barvian
Last active January 23, 2023 17:36
Show Gist options
  • Save barvian/874cb7d4a4914ce91b16a1f6add41303 to your computer and use it in GitHub Desktop.
Save barvian/874cb7d4a4914ce91b16a1f6add41303 to your computer and use it in GitHub Desktop.
Vite plugin for SvelteKit
<script context="module" lang="ts">
import type * as $types from './$types'
export const csr = false
export const getData = (async (event) => {
return {
server: event.data.server,
client: 'client data!'
}
}) satisfies $types.PageLoad
export const getServerData = (async () => {
return {
server: 'server data!'
}
}) satisfies $types.PageServerLoad
export const serverActions = {
default(event) {
return { success: true }
}
} satisfies $types.Actions
</script>
<script lang="ts">
import Button from '../components/Button.svelte'
export let data: $types.PageData
</script>
<Button />
Some client-side data: {data.client}
Some server-side data: {data.server}
<form method="POST">
<button type="submit">Submit</button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment