This is a server adapter for using koa with the Remix framework. It is more or less a straight-forward port of @remix-run/express.
npm install remix-koa-adapter
(or use pnpm, yarn, etc)
The package exports a Remix server adapter with a createRequestHandler
function. For more information on using Remix server adapters, please refer to the Remix documentation.
Usage Example:
import Koa from 'koa'
import serve from 'koa-static'
import path from 'path'
import { createRequestHandler } from 'remix-koa-adapter'
const app = new Koa()
const BUILD_DIR = path.join(process.cwd(), 'build')
app.use(serve('public'))
app.use(
createRequestHandler({
build: require(BUILD_DIR),
})
)
const port = process.env.PORT ?? 3000
app.listen(port, () => {
console.log(`✅ App listening on port ${port}`)
})
pnpm dev
Run minimal remix example against the adapter.pnpm test
(orpnpm test:coverage
) for running unit testspnpm build
to build the library for publishing
In the playground
directory, there is a minimal Remix application that can be
run against the adapter to manually validate the its behavior. More thorough
specs for the adapter can be found in the unit tests, which are ported from the
unit tests for @remix-run/express
, which I've considered the canonical adapter
implementation for the purpose of this project.