Sveltekit is a framework for building robust, fast web applications using Svelte. Zerops makes deploying and running Sveltekit apps, both server side rendered and static, a breeze. This recipe showcases the Static version, see zeropsio/recipe-svelte-nodejs for the Node.js version.
You can either click the deploy button to deploy directly on Zerops, or manually copy the import yaml to the import dialog in the Zerops app.
This recipe is ready for production as is, and will scale horizontally by adding more containers in case of high traffic surges. If you want to achieve the highest baseline reliability and resiliace, start with at least two containers (add minContainers: 2
in recipe YAML in the app
service section, or change the minimum containers in "Automatic Scaling configuration" section of service detail).
If you want to modify your existing SvelteKit app to efficiently run on Zerops, follow these steps:
pnpm i -D @sveltejs/adapter-static
svelte.config.js
to enable SSG. Also, ensure you have @sveltejs/vite-plugin-svelte
to avoid errors.import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter(),
},
preprocess: vitePreprocess(),
};
export default config;
src/routes/+layout.ts
:// export const ssr = false; default is false
export const prerender = true;
Now, just add the zerops.yml file to the root of your project.
Need help setting your project up? Join Zerops Discord community.