I replaced `adapter-cloudflare-workers` with `adapter-cloudflare`, it works fine, i am going crazy

I am building a personal blog website with sveltekit and as i am using mdsvex to handle the markdown articles serverside in a +page.server.js file, which to my understanding is considered SSR, i went on to use Cloudflare (CF) Workers instead of CF Pages. This means i ran this command to initialize my svelte project:
npm create cloudflare@latest my-svelte-app -- --framework=svelte --experimental
npm create cloudflare@latest my-svelte-app -- --framework=svelte --experimental
as mentioned in the CF Docs and i edited my svelte.config.js file to look like this:
import adapter from '@sveltejs/adapter-cloudflare-workers';
import { mdsvex } from 'mdsvex';
import rehypeSlug from 'rehype-slug';

/** @type {import('@sveltejs/kit').Config} */
​const config = {
​kit: {
​adapter: adapter({
config: 'wrangler.json',
​platformProxy: {
configPath: 'wrangler.json',
environment: undefined,
experimentalJsonConfig: false,
persist: false
}
})
},

​preprocess: mdsvex({
extensions: ['.svx', '.md'],
rehypePlugins: [rehypeSlug]
}),
extensions: ['.svelte', '.svx', '.md']
};

export default config;
import adapter from '@sveltejs/adapter-cloudflare-workers';
import { mdsvex } from 'mdsvex';
import rehypeSlug from 'rehype-slug';

/** @type {import('@sveltejs/kit').Config} */
​const config = {
​kit: {
​adapter: adapter({
config: 'wrangler.json',
​platformProxy: {
configPath: 'wrangler.json',
environment: undefined,
experimentalJsonConfig: false,
persist: false
}
})
},

​preprocess: mdsvex({
extensions: ['.svx', '.md'],
rehypePlugins: [rehypeSlug]
}),
extensions: ['.svelte', '.svx', '.md']
};

export default config;
based on the Svelte Docs and after some trial and error my wrangler.json file looked like this, and everything worked fine, website deployed successfully etc:
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "my-svelte-app",
"main": ".svelte-kit/cloudflare/_worker.js",
"compatibility_date": "2025-01-26",
"site": {
"bucket": ".svelte-kit/cloudflare",
"include": [
"*"
],
"exclude": [
"*.map"
]
},
"routes": [
{
"pattern": "mydomainname.com/*",
"zone_name": "mydomainname.com"
}
]
}
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "my-svelte-app",
"main": ".svelte-kit/cloudflare/_worker.js",
"compatibility_date": "2025-01-26",
"site": {
"bucket": ".svelte-kit/cloudflare",
"include": [
"*"
],
"exclude": [
"*.map"
]
},
"routes": [
{
"pattern": "mydomainname.com/*",
"zone_name": "mydomainname.com"
}
]
}
But...
1 Reply
Bones
BonesOP3d ago
But going through the CF Docs i came across the following bit:
Use Workers Static Assets Instead

You should use [Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/) to host full-stack applications instead of Workers Sites. Do not use Workers Sites for new projects.
Use Workers Static Assets Instead

You should use [Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/) to host full-stack applications instead of Workers Sites. Do not use Workers Sites for new projects.
naturally, i replaced the following part of my wrangler.json:
"site": {
"bucket": ".svelte-kit/cloudflare",
"include": [
"*"
],
"exclude": [
"*.map"
]
},
"site": {
"bucket": ".svelte-kit/cloudflare",
"include": [
"*"
],
"exclude": [
"*.map"
]
},
with this:
"assets": {
"directory": ".svelte-kit/cloudflare"
},
"assets": {
"directory": ".svelte-kit/cloudflare"
},
as mentioned in the CF Docs. When attempting to run npm run preview though to test if everything is ok with the worker locally, i got the following error:
> Using @sveltejs/adapter-cloudflare-workers
error during build:
Error: You must specify site.bucket in wrangler.json. Consult https://developers.cloudflare.com/workers/platform/sites/con
figuration
> Using @sveltejs/adapter-cloudflare-workers
error during build:
Error: You must specify site.bucket in wrangler.json. Consult https://developers.cloudflare.com/workers/platform/sites/con
figuration
I turned to the almighty ChatGPT which suggested replacing adapter-cloudflare-workers with adapter-cloudflare in the svelte.config.js file, i did that:
import adapter from '@sveltejs/adapter-cloudflare';
import { mdsvex } from 'mdsvex';
import rehypeSlug from 'rehype-slug';

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter()
},
preprocess: mdsvex({
extensions: ['.svx', '.md'],
rehypePlugins: [rehypeSlug]
}),
extensions: ['.svelte', '.svx', '.md']
};

export default config;
import adapter from '@sveltejs/adapter-cloudflare';
import { mdsvex } from 'mdsvex';
import rehypeSlug from 'rehype-slug';

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter()
},
preprocess: mdsvex({
extensions: ['.svx', '.md'],
rehypePlugins: [rehypeSlug]
}),
extensions: ['.svelte', '.svx', '.md']
};

export default config;
and to my surprise, it worked! npm run preview and npm run deploy ran successfully and everything works in the deployed website. My questions are: 1. what the hell is going on? 😄 2. am i using cloudflare workers or cloudflare pages right now? 3. on the cloudflare dashboard under Workers & Pages i see the worker that i initially created, i know it's a worker because: - it deploys on urls that look like this https://my-svelte-app.mydomainname.workers.dev/ - after i click on the worker i can see in the "Version History" table -> Source column -> it says "wrangler" - in the package.json i can see that the npm run preview and npm run deploy commands are clearly using wrangler. Wrangler is supposed to be a CF Workers thing, not a CF pages thing right? If everything points to me using CF Workers, why is adapter-cloudflare working just fine? 4. Do CF Pages support SSR? 5. Is it possible to make the Workers Static Assets configuration in the wrangler.json file to somehow work with adapter-cloudflare-workers without getting the error mentioned above? 6. and finally, should i use adapter-cloudflare-workers with adapter-cloudflare and why? Thanks for reading my wall, i am new to all this so i might have obvious mistakes in my thinking process 😄

Did you find this page helpful?