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:

    1. const express = require("express");
    2. const {
    3. createRequestHandler
    4. } = require("@remix-run/express");
    5. // needs to handle all verbs (GET, POST, etc.)
    6. app.all(
    7. "*",
    8. createRequestHandler({
    9. // `remix build` and `remix dev` output files to a build directory, you need
    10. // to pass that build to the request handler
    11. build: require("./build"),
    12. // return anything you want here to be available as `context` in your
    13. // loaders and actions. This is where you can bridge the gap between Remix
    14. // and your server
    15. getLoadContext(req, res) {
    16. }
    17. })
    18. );

    Here’s an example with Architect (AWS):

    1. const {
    2. createRequestHandler
    3. } = require("@remix-run/vercel");
    4. module.exports = createRequestHandler({
    5. build: require("./build")
    6. });

    Here’s an example with Netlify:

    Here’s an example with the simplified Cloudflare Workers API:

    1. import { createEventHandler } from "@remix-run/cloudflare-workers";
    2. import * as build from "../build";

    Here’s an example with the lower level Cloudflare Workers API: