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

twikoo-cloudflare

v1.6.40

Published

A simple, safe, free comment system.

Readme

Cloudflare deployment for twikoo comment system

This is the Cloudflare deployment for twikoo comment system. Compared to other deployments like Vercel/Netlify + MongoDB, it greatly improved the cold start latency (6s -> <0.5s). The latency improvement largely comes from tremendous optimizations on Cloudflare workers as well as integrated environment between HTTP server and database (Cloudflare D1).

Steps for the deployment

  1. Install npm packages:
npm install
  1. Because the free tier of Cloudflare workers has a strict 1MiB limit on the bundle size, we need to manually delete some packages to keep the bundle within the limit. These packages can't be used anyway due to the Node.js compatibility issues of Cloudflare workers.
echo "" > node_modules/jsdom/lib/api.js
echo "" > node_modules/tencentcloud-sdk-nodejs/tencentcloud/index.js
echo "" > node_modules/nodemailer/lib/nodemailer.js
  1. Login to your Cloudflare account:
npx wrangler login
  1. Create the Cloudflare D1 database and set up the schema:
npx wrangler d1 create twikoo
  1. Copy 2 lines of database_name and database_id from the output of the previous step, and paste them into wrangler.toml file, replacing the original values.
  2. Set up the Cloudflare D1 schema:
    npx wrangler d1 execute twikoo --remote --file=./schema.sql
  3. Create the Cloudflare R2 Storage:
    npx wrangler r2 bucket create twikoo
  4. Update the domain of R2 into wrangler.toml file, replacing the R2_PUBLIC_URL value.
  5. Deploy the Cloudflare worker:
npx wrangler deploy --minify
  1. If everything works smoothly, you will see something like: https://twikoo-cloudflare.<your user name>.workers.dev in the commandline. You can visit the address. If everything is set up perfectly, you're expected to see a line like that in your browser:
{"code":100,"message":"Twikoo 云函数运行正常,请参考 https://twikoo.js.org/frontend.html 完成前端的配置","version":"1.6.33"}
  1. When you set up the front end, the address in step 6 (including the https:// prefix) should be used as the envId field in twikoo.init.

Auto deploy: See the blog

Known limitations

Because Cloudflare workers are only partially compatible with Node.js, there are certain functional limitations for the twikoo Cloudflare deployment due to compatibility issues:

  1. Environment variables (process.env.XXX) can't be used to control the behavior of the app.
  2. Tencent Cloud can't be integrated.
  3. Can't find the location based on ip address (compatibility issue of the @imaegoo/node-ip2region package).
  4. Package dompurify can't be used to sanitize the comments due to compatibility issue of jsdom package. Instead, we're using xss package for XSS sanitization.
  5. In this deployment, we don't normalize URL path between /some/path/ and /some/path. This is because it's not easy to write a Cloudflare D1 SQL query to unify these 2 kinds of paths. If your website can have paths with and without the trailing / for the same page, you can explicitly set the path field in twikoo.init.
  6. Image uploading instead of using Cloudflare R2 Storage.
  7. Since using axios-cf-worker, pushoo.js works well.

Configure for email notifications

Because of the compatibility issues of nodemailer package, the email integration via SMTP for sending notifications won't work directly. Instead, in this worker, we support email notifications via SendGrid's HTTPS API. To enable the email integration via SendGrid, you can follow the steps below:

  1. Ensure you have a usable SendGrid account (SendGrid offers a free-tier for sending up to 100 emails per day) or MailChannels account (free for 3000 emails per month), and create an API key.
  2. Set the following fields in the config:
  • SENDER_EMAIL: The email address of the sender. Needs to verify it in SendGrid.
  • SENDER_NAME: The name shown as the sender.
  • SMTP_SERVICE: SendGrid.
  • SMTP_USER: Provide some non-empty value.
  • SMTP_PASS: The API key.
  1. Optionally, you can set other config values to customize how the notification emails look like.
  2. In the configuration page, click Send test email button to make sure the integration works well.
  3. In your email provider, make sure the incoming emails aren't classified as spam.

If you encounter any issues, or have any questions for this deployment, you can send an email to [email protected].