Use SvelteKit as a handler in the ExpressJs project

Photo by Gabriel Heinzer on Unsplash

Why ExpressJs and SvelteKit?

SvelteKit is an amazing web development framework and is quickly developed. However, there’re many issues that SvelteKit doesn’t support yet and developers need to fall back on server applications like ExpressJs.

This tutorial introduce you how to combine use SvelteKit as a handler in ExpressJs project.

Init SvelteKit project with express and esbuild

Create index.js at project root

Create esbuild.js at project root

You need the config banner.js because esbuild doesn’t polyfill dynamic import with require function. This script simply overwrites the build/index.js from SvelteKit with the index.jsof express.

Setup package.json

Discussion

With this building config, you can deploy the build folder and start the server with command node build. You can make urself a script for live reload while developing the app with nodemon

Conclusion

You should stay with SvelteKit as much as possible and only implement this solution when you need features that SvelteKit doesn’t support yet.

--

--

--

A regular mammal

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

OAuth using MEVN Stack

Typescript

# Higher-Order Functions in JavaScript

What is CSS display property?

My Study Tips for the JS129 Assessment

Competence Hierarchy adapted from Noel Burch by Igor Kokcharov

How Much Does React Native App Development Cost?| Systango

21 ways to not break your ScandiPWA theme

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tran Chien

Tran Chien

A regular mammal

More from Medium

Serverless playwright/firebase functions

Vite — Perfect build tool for Web development

Object Oriented Shell for Web Devs

Push notification in browser and how to use it using Javascript