Skip to content

Instantly share code, notes, and snippets.

@Glench
Last active December 19, 2020 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Glench/5a1d0e8043de3c029b1e8afcb6453a88 to your computer and use it in GitHub Desktop.
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
<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