Skip to content

Commit f3c3d10

Browse files
authored
docs: update tips for accessing the file system (#11683)
1 parent b8d0429 commit f3c3d10

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,4 @@ You may wish to refer to [Cloudflare's documentation for deploying a SvelteKit s
108108

109109
### Accessing the file system
110110

111-
You can't access the file system through methods like `fs.readFileSync` in Serverless/Edge environments. If you need to access files that way, do that during building the app through [prerendering](https://kit.svelte.dev/docs/page-options#prerender). If you have a blog for example and don't want to manage your content through a CMS, then you need to prerender the content (or prerender the endpoint from which you get it) and redeploy your blog everytime you add new content.
111+
You can't use `fs` in Cloudflare Workers — you must [prerender](https://kit.svelte.dev/docs/page-options#prerender) the routes in question.

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
@@ -127,4 +127,4 @@ When deploying to workers, the server generated by SvelteKit is bundled into a s
127127

128128
### Accessing the file system
129129

130-
You can't access the file system through methods like `fs.readFileSync` in Serverless/Edge environments. If you need to access files that way, do that during building the app through [prerendering](https://kit.svelte.dev/docs/page-options#prerender). If you have a blog for example and don't want to manage your content through a CMS, then you need to prerender the content (or prerender the endpoint from which you get it) and redeploy your blog everytime you add new content.
130+
You can't use `fs` in Cloudflare Workers — you must [prerender](https://kit.svelte.dev/docs/page-options#prerender) the routes in question.

documentation/docs/25-build-and-deploy/80-adapter-netlify.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,8 @@ Additionally, you can add your own Netlify functions by creating a directory for
111111

112112
### Accessing the file system
113113

114-
You can't access the file system through methods like `fs.readFileSync` in Serverless/Edge environments. If you need to access files that way, do that during building the app through [prerendering](https://kit.svelte.dev/docs/page-options#prerender). If you have a blog for example and don't want to manage your content through a CMS, then you need to prerender the content (or prerender the endpoint from which you get it) and redeploy your blog everytime you add new content.
114+
You can't use `fs` in edge deployments.
115+
116+
You _can_ use it in serverless deployments, but it won't work as expected, since files are not copied from your project into your deployment. Instead, use the `read` function from `$app/server` to access your files. `read` does not work inside edge deployments (this may change in future).
117+
118+
Alternatively, you can [prerender](https://kit.svelte.dev/docs/page-options#prerender) the routes in question.

documentation/docs/25-build-and-deploy/90-adapter-vercel.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,8 @@ Projects created before a certain date may default to using an older Node versio
157157

158158
### Accessing the file system
159159

160-
You can't access the file system through methods like `fs.readFileSync` in Serverless/Edge environments. If you need to access files that way, do that during building the app through [prerendering](https://kit.svelte.dev/docs/page-options#prerender). If you have a blog for example and don't want to manage your content through a CMS, then you need to prerender the content (or prerender the endpoint from which you get it) and redeploy your blog everytime you add new content.
160+
You can't use `fs` in edge functions.
161+
162+
You _can_ use it in serverless functions, but it won't work as expected, since files are not copied from your project into your deployment. Instead, use the `read` function from `$app/server` to access your files. `read` does not work inside routes deployed as edge functions (this may change in future).
163+
164+
Alternatively, you can [prerender](https://kit.svelte.dev/docs/page-options#prerender) the routes in question.

0 commit comments

Comments
 (0)