npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@inertianode/express

v1.0.4

Published

Express adapter for InertiaNode with a clean, intuitive API and automatic version detection.

Readme

@inertianode/express

Express adapter for InertiaNode with a clean, intuitive API and automatic version detection.

Installation

npm install @inertianode/express

Usage

Basic Setup

import express from "express";
import { inertiaExpressAdapter, InertiaExpress } from "@inertianode/express";

const app = express();

// Add the Inertia middleware with automatic version detection
app.use(inertiaExpressAdapter());

// Your routes
app.get("/", async (req, res) => {
  await InertiaExpress.renderForExpress(
    "Index",
    {
      title: "Welcome to Inertia Express",
    },
    req
  ).toExpressResponse(res);
});

Automatic Version Detection

The Express adapter now includes automatic version detection that works out of the box:

  • Development Mode: Automatically detects version from the Vite hot file (public/hot)
  • Production Mode: Automatically detects version from manifest files:
    • Vite: public/build/manifest.json
    • Laravel Mix: public/mix-manifest.json
    • Custom: public/manifest.json

No configuration needed! The version is automatically calculated based on your current mode and asset files.

Custom Version Detection

If you need custom version detection, you can still provide your own:

app.use(
  inertiaExpressAdapter({
    version: () => "my-custom-version",
    // or
    version: "static-version-string",
  })
);

Clean API

The new InertiaExpress API provides a much cleaner way to handle Inertia responses:

// ❌ Old way (verbose and error-prone)
app.get("/users", async (req, res) => {
  const webRequest = expressRequestToWebRequest(req);
  const response = await Inertia.render("Users", { users: [] }).toResponse(
    webRequest
  );

  response.headers.forEach((value, key) => {
    res.setHeader(key, value);
  });

  res.status(response.status).send(response.body);
});

// ✅ New way (clean and simple)
app.get("/users", async (req, res) => {
  await InertiaExpress.renderForExpress(
    "Users",
    {
      users: [],
    },
    req
  ).toExpressResponse(res);
});

Advanced Usage

You can also access the underlying InertiaResponse for advanced usage:

app.get("/complex", async (req, res) => {
  const expressResponse = InertiaExpress.renderForExpress(
    "Complex",
    {
      data: "some data",
    },
    req
  );

  // Access the underlying InertiaResponse
  const inertiaResponse = expressResponse.getInertiaResponse();

  // Do something with it...
  const webRequest = expressRequestToWebRequest(req);
  const webResponse = await inertiaResponse.toResponse(webRequest);

  // Custom handling
  res.status(webResponse.status).send(webResponse.body);
});

API Reference

InertiaExpress.renderForExpress(component, props, req)

Renders an Inertia component and returns an Express-specific response handler.

  • component (string): The component name to render
  • props (object): Props to pass to the component
  • req (ExpressRequest): The Express request object

Returns: ExpressInertiaResponse

ExpressInertiaResponse.toExpressResponse(res)

Sends the Inertia response to an Express response object.

  • res (ExpressResponse): The Express response object

ExpressInertiaResponse.getInertiaResponse()

Returns the underlying InertiaResponse for advanced usage.

Benefits

  1. Cleaner Code: No more manual request/response conversion
  2. Type Safety: Full TypeScript support with proper types
  3. Error Handling: Automatic header conversion and error handling
  4. Consistency: Same API across all Express routes
  5. Flexibility: Access to underlying InertiaResponse when needed