This is a boilerplate for svelte(-kit) and koa. It includes:
- Koa for building backend API
- Svelte kit for building FE js app
- Typescript support
- Build configuration and Dockerfile for easy to set up deploy
npx degit kaladivo/svelte-kit-koa-boilerplate my-new-super-cool-project
src/server
- Where the Koa server lives in
src/server/createServer.ts
- Creates Koa server, here you can add more routes
src/app
- SvelteKit app directory. See official docs to find out more.
First of all, run yarn install
to install all dependencies.
If you with to modify env vars, copy .env.example into .env and modify the contents to your liking.
yarn start:server
- starts koa dev server
yarn start:app
- starts svelte-kit dev server
yarn start
- runs both start commands concurrently
When developing the app, make sure to access Koa server (with the correct port) not the svelte dev server. Koa service is configured to automatically proxy requests to svelte server. This way we do not have to deal with CORS
yarn build:server
- builds Koa server into /build folder
yarn build:app
- builds Svelte-kit app into /build folder
yarn build
- runs both build commands concurrently
yarn serve
- Starts built koa server
- Include .env file setup
- Get rid warnings / errors
-
(!) Unresolved dependencies
when running build:sever -
Error: connect ECONNREFUSED 127.0.0.1:80
- when requesting page
-