Skip to main content

Getting Started

A quick guide to get started using Sveltekit OG

Setup: Installation & Plugin

Setting up SvelteKit OG is a two-step process: installing the core package and adding the necessary plugin to handle wasm file for build.

Installation

Install the package using your preferred package manager:

		pnpm i @ethercorps/sveltekit-og
	

Plugins Configuration

Sveltekit OG requires a plugin to handle native dependencies (WASM). You must use one of the two options below.

Vite Plugin

This is the preferred method for SvelteKit v4.1.0 onwards. It uses the simpler sveltekitOG function.

vite.config.js
		import { sveltekit } from '@sveltejs/kit/vite';
import { sveltekitOG } from '@ethercorps/sveltekit-og/plugin';
const config = {
	plugins: [sveltekit(), sveltekitOG()]
};
 
export default config;
	

Rollup Plugin

This plugin is primarily exist because of my own mistake.

vite.config.js
		import { sveltekit } from '@sveltejs/kit/vite';
import { rollupWasm } from '@ethercorps/sveltekit-og/plugin';
const config = {
	plugins: [sveltekit()],
	build: {
		rollupOptions: {
			plugins: [rollupWasm()]
		}
	}
};
 
export default config;
	

Next Steps

Once the package is installed and the plugin is configured, you are ready to create your first dynamic image by defining a SvelteKit server route and returning an ImageResponse.

  • For Svelte Components: If you prefer building your images using .svelte files, see the Basic Image Generation guide.
  • For Raw HTML: If you prefer using pure HTML strings with Tailwind CSS, see the Raw HTML guide.