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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@inertianode/core

v1.0.6

Published

Core package for InertiaNode providing the foundation for all adapters.

Readme

@inertianode/core

Core package for InertiaNode providing the foundation for all adapters.

Features

  • InertiaResponse: Core response handling for Inertia.js
  • VersionDetector: Automatic asset version detection with development mode support
  • Prop Helpers: Lazy, deferred, and merge props
  • HTML Renderer: Server-side HTML template generation
  • Headers: Inertia.js header constants

Version Detection

The VersionDetector class provides automatic asset version detection, inspired by the Laravel Inertia implementation. It properly handles both development and production modes.

Automatic Detection

import { VersionDetector } from "@inertianode/core";

// Automatically detect version from manifest files or hot file
const version = VersionDetector.detectVersion();
console.log("Detected version:", version);

Supported Manifest Files

The detector automatically checks for these files in order:

  1. public/build/manifest.json (Vite)
  2. public/mix-manifest.json (Laravel Mix)
  3. public/manifest.json (Custom)

Custom Configuration

// Use custom Vite options
const version = VersionDetector.detectVersion("public", {
  hotFile: "hot",
  buildDirectory: "build",
  manifestFilename: "manifest.json",
});

// Check if in development mode
const isDev = VersionDetector.isDevelopmentMode("public", "hot");

Create Version Detector Function

// Create a function for use with Inertia.setVersion()
const versionDetector = VersionDetector.createVersionDetector("public", {
  hotFile: "hot",
  buildDirectory: "build",
  manifestFilename: "manifest.json",
});
Inertia.setVersion(versionDetector);

How It Works

The version detector:

  1. Development Mode:

    • Checks for the hot file (e.g., public/hot)
    • Uses the hot file content as version
    • Ensures version changes when dev server restarts
  2. Production Mode:

    • Reads the manifest file content
    • Creates an MD5 hash of the content
    • Returns the hash as the version string
    • Returns null if no manifest file is found

This ensures that when your assets change, the version changes automatically, triggering a full page reload in Inertia.js.

Usage in Adapters

All InertiaNode adapters automatically use version detection when no explicit version is provided:

// Automatic version detection (default)
app.use(inertiaExpressAdapter());

// Custom version (overrides automatic detection)
app.use(
  inertiaExpressAdapter({
    version: "my-custom-version",
  })
);

// Custom Vite options with automatic version detection
app.use(
  inertiaExpressAdapter({
    vite: {
      publicDirectory: "dist",
      buildDirectory: "assets",
      hotFile: "hot",
    },
  })
);

API Reference

VersionDetector.detectVersion(publicDirectory?: string, viteOptions?: object): string | null

Detects the current asset version from manifest files or hot file.

  • publicDirectory (optional): Custom public directory path (default: 'public')
  • viteOptions (optional): Vite configuration options
    • hotFile: Hot file name (default: 'hot')
    • buildDirectory: Build directory name (default: 'build')
    • manifestFilename: Manifest filename (default: 'manifest.json')
  • Returns: Version string or null if no manifest/hot file found

VersionDetector.createVersionDetector(publicDirectory?: string, viteOptions?: object): () => string

Creates a version detector function for use with Inertia.setVersion().

  • publicDirectory (optional): Custom public directory path (default: 'public')
  • viteOptions (optional): Vite configuration options
  • Returns: Function that returns the current version string

VersionDetector.isDevelopmentMode(publicDirectory?: string, hotFile?: string): boolean

Checks if the application is currently in development mode.

  • publicDirectory (optional): Custom public directory path (default: 'public')
  • hotFile (optional): Hot file name (default: 'hot')
  • Returns: Boolean indicating if in development mode