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

node-ajax-seo

v1.4.1

Published

It deals with the most popular crawlers (Google, Twitter, Fb, LinkedIn, ...) redirecting them to static files but serving fresh pages to human users.

Readme

node-ajax-seo

Simple node plugin that deals with the most popular crawlers (Google, Facebook, Twitter, Baidu, LinkedIn), redirecting them to static snapshots while serves fresh pages to human users. It doesn't generate your snapshots, only routes. For that sort of things we have other nice modules ;-)

npmjs page

Installation

npm install node-ajax-seo --save

Usage

Options:

-nonAjaxCondition    (regex|string) regex condition (better choice this) or typical "if condition" as string to delimite non-ajax pages.

For example: 
/((^\/admin)|(^\/api)|(\.)|(^\/$))/ 
Same result as:
    "(req.url.indexOf('/admin') == -1 && req.url.indexOf('/api') == -1 && req.url.indexOf('.') == -1 && req.url != '/')"

-ajaxPath    (string) path to your main SPA .html by default.

-staticPages.path    (string) path to your static files.

-staticPages.separator    (string) in your static snapshots, filenames contain some token replacing "/" path ("[---]" by default).

-staticPages.basePath.url    (string) basepath is an special case: "when path is X, serve file Y" ("/" by default).

-staticPages.basePath.file    (string) ("index.html" by default). 

-debug		(boolean) Enables debug messages (false by default).

Examples


	var ajaxSeo = require("node-ajax-seo");

Minimal config:


	var siteConfig = {
        nonAjaxCondition: /((^\/admin)|(^\/api)|(\.)|(^\/$))/,
        ajaxPath: path.join(__dirname, 'assets', 'index.html'),
        staticPages: {
            path: path.join(__dirname, 'assets', 'dist', 'static'),
        }
    };

    ajaxSeo.dealWithAjax(siteConfig, req, res, next, function cbk(err) {
        if (err) {
            console.log(err);
        }
        else {
            console.log(siteConfig.appPrefix+'Sent:', path.join(filePath,fragment));
        }
    });

Normal config:

	
  	app.get("/*", function(req, res,next) {

	    /**
	     * It's necessary to define a pattern that matches with non ajax requests:
	     * In this example all the paths are ajax except:
	     *
	     * - /admin and /api paths.
	     * - resource requests.
	     * - root
	     **/

	    var siteConfig = {
	        nonAjaxCondition: /((^\/admin)|(^\/api)|(\.)|(^\/$))/,
	        ajaxPath: path.join(__dirname, 'assets', 'index.html'),
	        staticPages: {
	            path: path.join(__dirname, 'assets', 'dist', 'static'),
	            separator: "[---]",
	            basePath: {
	                url: "/",
	                file: "home.html"
	            }
	        },
	        debug: false
	    };

	    ajaxSeo.dealWithAjax(siteConfig, req, res, next, function cbk(err) {
	        if (err) {
	            console.log(err);

	            // if we don't have snapshot, we can serve 404 page, log miss request into DB, send a mail... whatevevr,
	            // but the best option in this case is to generate it and serve it on-the-fly (WIP).
	            console.log(siteConfig.appPrefix+"We serve the  default file caused by the inexistence of the requested one.");
	            //res.status(err.status).end();
	            res.sendfile(path.join(siteConfig.staticPages.path,siteConfig.staticPages.basePath.file));
	        }
	        else {
	            console.log(siteConfig.appPrefix+'Sent:', path.join(filePath,fragment));
	        }
	    });
	});

Tests

npm test (not yet)

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Authors

Eric Lara and Santi Pérez, powered by Ondho.

License

MIT

Roadmap