Open robthepaper opened 1 year ago
@robotpapier vercel and sveltekit has a comprehensive guide about deployment.
https://vercel.com/docs/frameworks/sveltekit https://kit.svelte.dev/docs/adapter-vercel
Using vercel adapter will build your app in public folder, it seems your svelte.config.js
is not set properly.
Glad it was helpful @robotpapier ! This example uses @sveltejs/adapter-node
so you'll need a server capable of running the built Node.js script. From what I can tell Vercel does not support WebSocket servers as part of their serverless function offering so I doubt you'll be able to use the Vercel adapter. One option you could look into is Cloudflare - it looks like they do offer support for WebSocket servers within Cloudflare Workers.
If your use case doesn't involve a lot of traffic I'd suggest hosting your site on a small server like the Amazon T2.micro EC2 instance.
@suhaildawood yeah indeed I saw that afterwards, thanks for the tips ! :)
Glad it was helpful @robotpapier ! This example uses
@sveltejs/adapter-node
so you'll need a server capable of running the built Node.js script. From what I can tell Vercel does not support WebSocket servers as part of their serverless function offering so I doubt you'll be able to use the Vercel adapter.
Could you elaborate on this? I was under the impression that this example app was a server and could be hosted directly on Vercel. I'm not sure I understand how a SvelteKit app can even be a serverless function. I'm not sure if there's some sort of requirement I'm missing..
@aeviou Yeah, as @suhaildawood said, and as in the Vercel docs, Vercel doesn't allow websockets connections, so there is no way It can work even if you can deploy it. Luckily for my project, my apps will run locally in production, so I didn't try it on Cloudfare yet with which it should theorically work. Hope it's clearer!
Ah yes. My misunderstanding was that I didn't understand that Vercel deployed the SvelteKit app as a single serverless function. Thanks for the clarification!
Hi @suhaildawood , thanks for this example of sveltekit + websocket. Works perfectly in development.
But I can't deploy it to vercel, can you give some clues on how we could make this work? I have this error on Vercel build :
Error: No Output Directory named "public" found after the Build completed. You can configure the Output Directory in your Project Settings.
Thanks