LogoDuyệtSr. Data Engineer
HomeAboutPhotosInsightsCV

Footer

Logo

Resources

  • Rust Tiếng Việt
  • /archives
  • /series
  • /tags
  • Status

me@duyet.net

  • About
  • LinkedIn
  • Resume
  • Projects

© 2026 duyet.net | Sr. Data Engineer | 2026-02-27

Detect robots in koa

Note: This post is over 11 years old. The information may be outdated.

Koa detect robots. Fast Middleware detect bot crawler for Koa.

Note (2025): This guide covers the koa-isbot middleware for Koa v1 and v2. The plugin approach is still valid for Koa applications. For modern alternatives, consider checking the User-Agent header directly using libraries like ua-parser-js or checking if newer bot detection packages are actively maintained.

Installation

npm install koa-isbot --save

Usage

const Koa = require('koa');
const isBot = require('koa-isbot');
const app = new Koa();

app.use(isBot());

app.use(function* (next) {
  console.log('isBot? ', this.state.isBot);
  // null or 'googlebot', 'bingbot', ...
});

app.listen(3000);

Update for Koa2

const Koa = require('koa');
const isBot = require('koa-isbot');
const app = new Koa();

app.use(isBot());

app.use(async (ctx, next) => {
  console.log('isBot? ', ctx.isBot);
  // null or 'googlebot', 'bingbot', ...
});

app.listen(3000);

Support list

  • Google bot - googlebot
  • Baidu - baiduspider
  • Guruji - gurujibot
  • Yandex - yandexbot
  • Slurp- slurp
  • MSN - msnbot
  • Bing - bingbot
  • Facebook - facebookexternalhit
  • Linkedin - linkedinbot
  • Twitter - twitterbot
  • Slack - slackbot
  • Telegram - telegrambot
  • Apple - applebot
  • Pingdom - pingdom
  • tumblr - tumblr

Source code

  • GitHub: https://github.com/duyet/koa-isbot
  • NPM: https://www.npmjs.com/package/koa-isbot

How to contribute

  1. Fork the project on Github (https://github.com/duyet/koa-isbot/fork)
  2. Create a topic branch for your changes
  3. Ensure that you provide documentation and test coverage for your changes (patches won’t be accepted without)
  4. Create a pull request on Github (these are also a great place to start a conversation around a patch as early as possible)
Feb 21, 2016·10 years ago
|Javascript|
Node.jsJavascript Framework
|Edit|

Related Posts

JavaPoly.js: chạy Java ngay trên trình duyệt Web

Polyfills native, hỗ trợ JVM, bạn có thể import file Jar, biên dịch và chạy trực tiếp mã Java ngay trên trình duyệt Web với JavaPoly, thư viện được viết bằng Javascript.

May 21, 2016·10 years ago
Read more

MEAN.js Fullstack

MEANJs là một web application framework cho NodeJS, nó là 1 stack kết hợp nhiều công nghệ, giúp bạn dễ dàng nhanh chóng và dễ dàng phát triển 1 ứng dụng Web SPA (Single Page Application). Cùng tìm hiểu nhé.

Apr 5, 2015·11 years ago
Read more

Resting và Spreading JavaScript Objects

Resting và spreading càng ngày được ưa chuộng vì sự tiện lợi của nó, sau đây là 7 tricks với JavaScript objects.

Mar 27, 2019·7 years ago
Read more

Javascript Weekly #10

Javascript Weekly #10 gửi đến cộng đồng một số tin tức JS mới: top frameworks 2017, Angular Next 4.0, Voca xử lý string cực kỳ mạnh, Hyper 1.0 - terminal on top JS, Vuetify, ...

Dec 17, 2016·9 years ago
Read more
On this page
  • Installation
  • Usage
  • Support list
  • Source code
  • How to contribute
On this page
  • Installation
  • Usage
  • Support list
  • Source code
  • How to contribute