Server Adapters
@remix-run/express
@remix-run/architect
@remix-run/vercel
@remix-run/netlify
@remix-run/cloudflare-workers
These adapters are imported into your server’s entry and is not used inside of your Remix app itself.
If you initialized your app with npx create-remix@latest
with something other than the built-in Remix App Server, you will note a server/index.js
file that imports and uses one of these adapters.
If you’re using the built-in Remix App Server, you don’t interact with this API
Creates a request handler for your server to serve the app. This is the ultimate entry point of your Remix application.
Here’s a full example with express:
const express = require("express");
const {
createRequestHandler
} = require("@remix-run/express");
// needs to handle all verbs (GET, POST, etc.)
app.all(
"*",
createRequestHandler({
// `remix build` and `remix dev` output files to a build directory, you need
// to pass that build to the request handler
build: require("./build"),
// return anything you want here to be available as `context` in your
// loaders and actions. This is where you can bridge the gap between Remix
// and your server
getLoadContext(req, res) {
}
})
);
Here’s an example with Architect (AWS):
const {
createRequestHandler
} = require("@remix-run/vercel");
module.exports = createRequestHandler({
build: require("./build")
});
Here’s an example with Netlify:
Here’s an example with the simplified Cloudflare Workers API:
import { createEventHandler } from "@remix-run/cloudflare-workers";
import * as build from "../build";
Here’s an example with the lower level Cloudflare Workers API: