Remote functions docs don't work
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
The docs don't work
Problem
The 'Remote functions' docs suffer from a few important problems:
- They can't be run 'as-is'. They rely on a fictional 'db' module.
- It's unclear how to set a variable value at the top level of a <script> tag. Perhaps it's obvious to smart people who understand Svelte, but it's not self-evident from the docs.
- Indeed, a simplified version of the docs' example under 'Query arguments' yields an error.
<script lang="ts">
import { getPost } from './data.remote';
const post = await getPost();
</script>
<h1>{post.title}</h1>
\[500\] GET /
Svelte error: await\_outside\_boundary
Cannot await outside a \`<svelte:boundary>\` with a \`pending\` snippet
https://svelte.dev/e/await\_outside\_boundary
at await\_outside\_boundary (node\_modules/svelte/src/internal/shared/errors.js:11:17)
at \_page (src/routes/+page.svelte:4:12)
at <anonymous> (.svelte-kit/generated/root.svelte:68:14)
at \_layout (src/routes/+layout.svelte:9:18)
Diagnosis
I found the source of the YouTube demo. That repo has a boundary in its top-level +layout.svelte.
Uncomment from the +layout.svelte and below to see it work.
Proposal
- The Remote functions docs should be self-contained. A user should be able to copy-paste and see it work.
- To make it more readable, the docs should keep using the same example. Changing from
getPosttogetPostsdoesn't seem necessary. - Therefore the docs should (a) simply use the code in the example below as
data.remote.tsand (b) link to a minimal live SvelteLab example so that users can see it work.
Example
Reproduction
Logs
System Info
(I'm running this on SvelteLab...)
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@sveltejs/adapter-auto: ^3.0.0 => 3.3.1
@sveltejs/kit: ^2.5.27 => 2.39.0
@sveltejs/vite-plugin-svelte: ^5.0.0 => 5.1.1
svelte: ^5 => 5.38.10
vite: ^6.0.0 => 6.3.6
Severity
annoyance
Additional Information
@dummdidumm this is probably relevant to you. I'm happy to submit a PR if you agree with my diagnosis and proposal.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Remote functions documentation, especially the Query arguments section, and compare its examples with the linked SvelteLab reproduction and its +layout.svelte, +page.svelte, and data.remote.js files. Done means the docs use a self-contained working example, explain the top-level await boundary, and link to a minimal live example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100