Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does SvelteKit support background jobs

Where should I put codes that are supposed to always run like croner? I can't find it here.

Edit:

It seems like it's not possible at the moment. Should I use a separate backend?

like image 284
M Imam Pratama Avatar asked Oct 23 '25 11:10

M Imam Pratama


2 Answers

Svelte does not support come with support for background jobs, but if you are running it as a node app then you can add a library for background jobs. I'd suggest you checkout Querril from https://docs.quirrel.dev/api/sveltekit/ .

Also, you can create API routes with Sveltekit which can do whatever you want, they don't have to render HTML and can respond to any HTTP verbs: https://docs.quirrel.dev/api/sveltekit/

like image 179
futuregerald Avatar answered Oct 25 '25 11:10

futuregerald


SvelteKit backend is only for serving web pages. It does not do any tasks that are not directly related to HTTP requests and responses.

To have cron jobs with your SvelteKit site, I would recommend any generic Node.js + TypeScript cron solution. This also requires you to run a full server-side worker process, because timed tasks cannot be with static hosting services.

Alternatively if you use any special hosting with serverless, functions, etc. they often offer timed tasks as the part of the package.

like image 45
Mikko Ohtamaa Avatar answered Oct 25 '25 11:10

Mikko Ohtamaa