# Kirby + Svelte/Sapper

**URL:** <https://forum.getkirby.com/t/kirby-svelte-sapper/20609>\
**Category:** Questions\
**Tags:** v3\
**Created:** [January 1, 2021, 12:24pm UTC](https://forum.getkirby.com/t/kirby-svelte-sapper/20609 "2021-01-01T12:24:06Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![silvan](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/silvan/32/8097_2.png) [@silvan](https://forum.getkirby.com/u/silvan)\
**Post date:** [April 29, 2021, 9:45pm UTC](https://forum.getkirby.com/t/kirby-svelte-sapper/20609/4 "2021-04-29T21:45:16Z")

</div>

Another simple approach (if you only need to read public data) I used on one site is to simply return JSON from your templates. It was really straight-forward and was close to working with normal templates. You can then use the URLs / routing provided by Kirby as your custom API.

Some sample code:

```auto
<?php
$data = [
  'text' => $page->text()->kirbytext()->value(),
  'title' => $page->title()->value(),
  'uid' => $page->uid()
];

// set response content type to `application/json`
$kirby->response()->json();

echo json_encode($data);

```

Edit: This [Vue starterkit](https://github.com/johannschopplich/kirby-vue3-starterkit) mentioned by @texnixe in [this thread](https://forum.getkirby.com/t/kirby-3-headless-setup/20970) seems to use the same idea.

---

_[View the full topic](https://forum.getkirby.com/t/kirby-svelte-sapper/20609)._
