Last active
December 19, 2020 19:02
-
-
Save Glench/5a1d0e8043de3c029b1e8afcb6453a88 to your computer and use it in GitHub Desktop.
An idea for how SvelteKit could bridge the front-end/back-end gap more elegantly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script context="backend"> | |
// /routes/index.svelte | |
import db from '/db'; | |
export async function get(req, abort, redirect) { | |
const user = await db.User.findOne({where: {id: req.query.user_id}}); | |
return {user} | |
} | |
</script> | |
<script> | |
export var user; | |
</script> | |
<h1>Hi {user.name}!</h1> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment