Skip to content

Commit 1997c0d

Browse files
docs: improve FAQ navbar (#13450)
* docs: improve FAQ navbar * chore: Fix build errors, probably --------- Co-authored-by: S. Elliott Johnson <[email protected]>
1 parent 3b2caa1 commit 1997c0d

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

documentation/docs/25-build-and-deploy/70-adapter-cloudflare-workers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ For testing the build, you should use [wrangler](https://developers.cloudflare.c
133133

134134
### Worker size limits
135135

136-
When deploying to workers, the server generated by SvelteKit is bundled into a single file. Wrangler will fail to publish your worker if it exceeds [the size limits](https://developers.cloudflare.com/workers/platform/limits/#worker-size) after minification. You're unlikely to hit this limit usually, but some large libraries can cause this to happen. In that case, you can try to reduce the size of your worker by only importing such libraries on the client side. See [the FAQ](./faq#How-do-I-use-X-with-SvelteKit-How-do-I-use-a-client-side-only-library-that-depends-on-document-or-window) for more information.
136+
When deploying to workers, the server generated by SvelteKit is bundled into a single file. Wrangler will fail to publish your worker if it exceeds [the size limits](https://developers.cloudflare.com/workers/platform/limits/#worker-size) after minification. You're unlikely to hit this limit usually, but some large libraries can cause this to happen. In that case, you can try to reduce the size of your worker by only importing such libraries on the client side. See [the FAQ](./faq#How-do-I-use-a-client-side-library-accessing-document-or-window) for more information.
137137

138138
### Accessing the file system
139139

documentation/docs/60-appendix/10-faq.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Libraries work best in the browser with Vite when they distribute an ESM version
5959
6060
If you are still encountering issues we recommend searching both [the Vite issue tracker](https://github.com/vitejs/vite/issues) and the issue tracker of the library in question. Sometimes issues can be worked around by fiddling with the [`optimizeDeps`](https://vitejs.dev/config/#dep-optimization-options) or [`ssr`](https://vitejs.dev/config/#ssr-options) config values though we recommend this as only a short-term workaround in favor of fixing the library in question.
6161
62-
## How do I use the view transitions API with SvelteKit?
62+
## How do I use the view transitions API?
6363
6464
While SvelteKit does not have any specific integration with [view transitions](https://developer.chrome.com/docs/web-platform/view-transitions/), you can call `document.startViewTransition` in [`onNavigate`]($app-navigation#onNavigate) to trigger a view transition on every client-side navigation.
6565
@@ -81,15 +81,13 @@ onNavigate((navigation) => {
8181
8282
For more, see ["Unlocking view transitions"](/blog/view-transitions) on the Svelte blog.
8383
84-
## How do I use X with SvelteKit?
85-
86-
Make sure you've read the [documentation section on integrations](./integrations). If you're still having trouble, solutions to common issues are listed below.
87-
88-
### How do I setup a database?
84+
## How do I set up a database?
8985
9086
Put the code to query your database in a [server route](./routing#server) - don't query the database in .svelte files. You can create a `db.js` or similar that sets up a connection immediately and makes the client accessible throughout the app as a singleton. You can execute any one-time setup code in `hooks.server.js` and import your database helpers into any endpoint that needs them.
9187
92-
### How do I use a client-side only library that depends on `document` or `window`?
88+
You can use [the Svelte CLI](/docs/cli/overview) to automatically set up database integrations.
89+
90+
## How do I use a client-side library accessing `document` or `window`?
9391
9492
If you need access to the `document` or `window` variables or otherwise need code to run only on the client-side you can wrap it in a `browser` check:
9593
@@ -157,7 +155,7 @@ Finally, you may also consider using an `{#await}` block:
157155
{/await}
158156
```
159157
160-
### How do I use a different backend API server?
158+
## How do I use a different backend API server?
161159
162160
You can use [`event.fetch`](./load#Making-fetch-requests) to request data from an external API server, but be aware that you would need to deal with [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), which will result in complications such as generally requiring requests to be preflighted resulting in higher latency. Requests to a separate subdomain may also increase latency due to an additional DNS lookup, TLS setup, etc. If you wish to use this method, you may find [`handleFetch`](./hooks#Server-hooks-handleFetch) helpful.
163161
@@ -175,7 +173,7 @@ export function GET({ params, url }) {
175173
176174
(Note that you may also need to proxy `POST`/`PATCH` etc requests, and forward `request.headers`, depending on your needs.)
177175
178-
### How do I use middleware?
176+
## How do I use middleware?
179177
180178
`adapter-node` builds a middleware that you can use with your own server for production mode. In dev, you can add middleware to Vite by using a Vite plugin. For example:
181179
@@ -209,6 +207,8 @@ export default config;
209207
210208
See [Vite's `configureServer` docs](https://vitejs.dev/guide/api-plugin.html#configureserver) for more details including how to control ordering.
211209
210+
## How do I use Yarn?
211+
212212
### Does it work with Yarn 2?
213213
214214
Sort of. The Plug'n'Play feature, aka 'pnp', is broken (it deviates from the Node module resolution algorithm, and [doesn't yet work with native JavaScript modules](https://github.com/yarnpkg/berry/issues/638) which SvelteKit — along with an [increasing number of packages](https://blog.sindresorhus.com/get-ready-for-esm-aa53530b3f77) — uses). You can use `nodeLinker: 'node-modules'` in your [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc#nodeLinker) file to disable pnp, but it's probably easier to just use npm or [pnpm](https://pnpm.io/), which is similarly fast and efficient but without the compatibility headaches.

documentation/docs/60-appendix/20-integrations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ Since SvelteKit projects are built with Vite, you can use Vite plugins to enhanc
4949

5050
## Integration FAQs
5151

52-
The SvelteKit FAQ has a [how to do X with SvelteKit](./faq#How-do-I-use-X-with-SvelteKit), which may be helpful if you still have questions.
52+
The SvelteKit FAQ has a [how to do X with SvelteKit](./faq#How-do-I-set-up-a-database), which may be helpful if you still have questions.

0 commit comments

Comments
 (0)