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

astro-qiita-loader

v0.2.0

Published

Qiita API Loader for Astro

Readme

日本語版はこちら

Astro Qiita Loader

This package provides a Qiita loader for Astro, allowing you to use Qiita posts as content collections.

Requirements

The build-time qiitaLoader supports Astro 5, 6, and 7. The qiitaLiveLoader requires Astro 6 or 7. Development and the Astro 7 demo require Node.js 22.22.0 or later.

Installation

npm install astro-qiita-loader

Usage

You can use the qiitaLoader in your content configuration at src/content.config.ts:

import { defineCollection } from "astro:content";
import { qiitaLoader } from "astro-qiita-loader";

export const collections = {
  qiitas: defineCollection({
    loader: qiitaLoader({
      url: "https://qiita.com/api/v2/items",
      authToken: "your_qiita_api_token", // Optional
    }),
  }),
};

You can then use these like any other content collection in Astro:

---
import { getCollection } from "astro:content";

const qiitas = await getCollection("qiitas");
---

<ul>
  {qiitas.map((qiita) => (
    <li>
      <a href={qiita.data.url} target="_blank" rel="noopener">
        {qiita.data.title}
      </a>
    </li>
  ))}
</ul>

Options

qiitaLoader has the following options:

  • url: Qiita API URL. Set the URL of the posts you want to fetch.
  • authToken: Qiita API authentication token. Optional: 1000 req/hr with token, 60 req/hr without

Synchronization

Each load fetches the configured URL and validates all returned entries before updating the collection. Astro uses each entry's digest to skip writes for unchanged entries. Entries absent from the response are removed, including when the response is empty.

If fetching, JSON parsing, or schema validation fails, the load rejects and existing entries remain unchanged. Synchronization covers only the configured URL's response; the loader does not fetch additional pages.

Live collections (Astro 6 and 7)

Use qiitaLiveLoader from astro-qiita-loader/live to fetch articles at runtime, without rebuilding your site. Define the collection in src/live.config.ts:

import { defineLiveCollection } from "astro:content";
import { qiitaLiveLoader } from "astro-qiita-loader/live";

export const collections = {
  qiitas: defineLiveCollection({
    loader: qiitaLiveLoader({
      url: "https://qiita.com/api/v2/users/t0yohei/items",
      authToken: () => process.env.QIITA_AUTH_TOKEN, // Optional
    }),
  }),
};

Query it from a page rendered on demand:

---
import { getLiveCollection } from "astro:content";

export const prerender = false;
const { entries: qiitas, error } = await getLiveCollection("qiitas");
if (error) throw error;
---

<ul>
  {qiitas.map((qiita) => (
    <li><a href={qiita.data.url}>{qiita.data.title}</a></li>
  ))}
</ul>

On-demand pages require an Astro server adapter. Keep any page caching policy in your site configuration; the loader does not cache API responses.

qiitaLiveLoader accepts a url for a Qiita article-list endpoint and an optional authToken. The token can be a string or a synchronous function returning a string or undefined. The function is called at the start of each load, so it can read runtime credentials.

Each load starts at page 1, requests 100 articles per page, and continues until a page contains fewer than 100 articles. Other URL query parameters are preserved. Each API request has a 10-second timeout. HTTP errors, invalid JSON, and schema validation errors fail the load instead of returning empty or partial results.

Entries use the existing Item type, parse dates as Date objects, and expose rendered_body through Astro's render() helper. For a single entry, use getLiveEntry("qiitas", { id: "article-id" }); this also fetches the collection's pages before finding the requested entry.

Sample

See the sample for reference.

License

MIT