You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/svelte.dev/content/docs/kit/20-core-concepts/20-load.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,7 +189,7 @@ Conceptually, they're the same thing, but there are some important differences t
189
189
190
190
Server `load` functions _always_ run on the server.
191
191
192
-
By default, universal `load` functions run on the server during SSR when the user first visits your page. They will then run again during hydration, reusing any responses from [fetch requests](#Making-fetch-requests). All subsequent invocations of universal `load` functions happen in the browser. You can customize the behavior through [page options](page-options). If you disable [serverside rendering](page-options#ssr), you'll get an SPA and universal `load` functions _always_ run on the client.
192
+
By default, universal `load` functions run on the server during SSR when the user first visits your page. They will then run again during hydration, reusing any responses from [fetch requests](#Making-fetch-requests). All subsequent invocations of universal `load` functions happen in the browser. You can customize the behavior through [page options](page-options). If you disable [server-side rendering](page-options#ssr), you'll get an SPA and universal `load` functions _always_ run on the client.
193
193
194
194
If a route contains both universal and server `load` functions, the server `load` runs first.
Copy file name to clipboardExpand all lines: apps/svelte.dev/content/docs/kit/20-core-concepts/60-remote-functions.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ title: Remote functions
7
7
<p>Available since 2.27</p>
8
8
</blockquote>
9
9
10
-
Remote functions are a tool for type-safe communication between client and server. They can be _called_ anywhere in your app, but always _run_ on the server, and as such can safely access [server-only modules](server-only-modules) containing things like environment variables and database clients.
10
+
Remote functions are a tool for type-safe communication between client and server. They can be _called_ anywhere in your app, but always _run_ on the server, and thus can safely access [server-only modules](server-only-modules) containing things like environment variables and database clients.
11
11
12
12
Combined with Svelte's experimental support for [`await`](/docs/svelte/await-expressions), it allows you to load and manipulate data directly inside your components.
13
13
@@ -114,7 +114,7 @@ Query functions can accept an argument, such as the `slug` of an individual post
114
114
115
115
let { params } =$props();
116
116
117
-
constpost=getPost(params.slug);
117
+
constpost=awaitgetPost(params.slug);
118
118
</script>
119
119
120
120
<h1>{post.title}</h1>
@@ -161,7 +161,7 @@ Any query can be updated via its `refresh` method:
161
161
</button>
162
162
```
163
163
164
-
> [!NOTE] Queries are cached while they're on the page, meaning `getPosts() ===getPosts()`. As such, you don't need a reference like `constposts=getPosts()` in order to refresh the query.
164
+
> [!NOTE] Queries are cached while they're on the page, meaning `getPosts() ===getPosts()`. This means you don't need a reference like `constposts=getPosts()` in order to refresh the query.
> [!NOTE] Svelte does not yet support asynchronous server-side rendering, and as such it's likely that you're only calling remote functions from the browser, rather than during prerendering. Because of this you will need to use `inputs`, for now. We're actively working on this roadblock.
660
+
> [!NOTE] Svelte does not yet support asynchronous server-side rendering, so it's likely that you're only calling remote functions from the browser, rather than during prerendering. Because of this, you will need to use `inputs`, for now. We're actively working on this roadblock.
661
661
662
662
By default, prerender functions are excluded from your server bundle, which means that you cannot call them with any arguments that were _not_ prerendered. You can set `dynamic:true` to change this behaviour:
Copy file name to clipboardExpand all lines: apps/svelte.dev/content/docs/kit/60-appendix/30-migrating-to-sveltekit-2.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ This inconsistency is fixed in version 2. Paths are either always relative or al
91
91
92
92
## Server fetches are not trackable anymore
93
93
94
-
Previously it was possible to track URLs from `fetch`es on the server in order to rerun load functions. This poses a possible security risk (private URLs leaking), and as such it was behind the `dangerZone.trackServerFetches` setting, which is now removed.
94
+
Previously it was possible to track URLs from `fetch`es on the server in order to rerun load functions. This poses a possible security risk (private URLs leaking), and for this reason it was behind the `dangerZone.trackServerFetches` setting, which is now removed.
95
95
96
96
## `preloadCode` arguments must be prefixed with `base`
97
97
@@ -105,7 +105,7 @@ Additionally, `preloadCode` now takes a single argument rather than _n_ argument
105
105
106
106
SvelteKit 1 included a function called `resolvePath` which allows you to resolve a route ID (like `/blog/[slug]`) and a set of parameters (like `{ slug: 'hello' }`) to a pathname. Unfortunately the return value didn't include the `base` path, limiting its usefulness in cases where `base` was set.
107
107
108
-
As such, SvelteKit 2 replaces `resolvePath` with a (slightly better named) function called `resolveRoute`, which is imported from `$app/paths` and which takes `base` into account.
108
+
For this reason, SvelteKit 2 replaces `resolvePath` with a (slightly better named) function called `resolveRoute`, which is imported from `$app/paths` and which takes `base` into account.
109
109
110
110
```js
111
111
---import { resolvePath } from'@sveltejs/kit';
@@ -128,7 +128,7 @@ SvelteKit 2 cleans this up by calling `handleError` hooks with two new propertie
128
128
129
129
The `$env/dynamic/public` and `$env/dynamic/private` modules provide access to _run time_ environment variables, as opposed to the _build time_ environment variables exposed by `$env/static/public` and `$env/static/private`.
130
130
131
-
During prerendering in SvelteKit 1, they are one and the same. As such, prerendered pages that make use of 'dynamic' environment variables are really 'baking in' build time values, which is incorrect. Worse, `$env/dynamic/public` is populated in the browser with these stale values if the user happens to land on a prerendered page before navigating to dynamically-rendered pages.
131
+
During prerendering in SvelteKit 1, they are one and the same. Thus, prerendered pages that make use of 'dynamic' environment variables are really 'baking in' build time values, which is incorrect. Worse, `$env/dynamic/public` is populated in the browser with these stale values if the user happens to land on a prerendered page before navigating to dynamically-rendered pages.
132
132
133
133
Because of this, dynamic environment variables can no longer be read during prerendering in SvelteKit 2 — you should use the `static` modules instead. If the user lands on a prerendered page, SvelteKit will request up-to-date values for `$env/dynamic/public` from the server (by default from a module called `/_app/env.js`) instead of reading them from the server-rendered HTML.
0 commit comments