remix-koa-adapter
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

remix-koa-adapter

build npm version License: MIT

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.

Installation & Usage

  • 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}`)
})

Contributing & Local Development

  • pnpm dev Run minimal remix example against the adapter.
  • pnpm test (or pnpm test:coverage) for running unit tests
  • pnpm 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.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i remix-koa-adapter

Weekly Downloads

95

Version

2.0.0

License

MIT

Unpacked Size

13.3 kB

Total Files

7

Last publish

Collaborators

  • michaelhelvey