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

rendu

v0.0.7

Published

🏎️ JavaScript Hypertext Preprocessor.

Downloads

35,775

Readme

rendu

🏎️ JavaScript Hypertext Preprocessor.

Rendu is a lightweight toolkit for mixing HTML and JavaScript with a focus on simplicity, standards and progressive rendering.

[!WARNING] This is an experimental PoC.

[!NOTE] See playground (online playground) for demos and syntax section for usage.

CLI

Using the rendu CLI, you can start a local web server to serve static files and render .html files as templates (powered by srvx).

npx rendu

Programmatic API

compileTemplate(template, opts)

Compile a template string into a render function.

Example:

import { compileTemplate } from "rendu";

const template = `
  <h1>{{ title }}</h1>
  <ul>
  <? for (const item of items) { ?>
    <li>{{ item }}</li>
  <? } ?>
  </ul>
`;

const render = compileTemplate(template, { stream: false });

const html = await render({ title: "My List", items: ["Item 1", "Item 2", "Item 3"] });
console.log(html);
// Output:
// <h1>My List</h1>
// <ul>
//   <li>Item 1</li>
//   <li>Item 2</li>
//   <li>Item 3</li>
// </ul>

compileTemplateToString(template, opts, asyncWrapper?)

Compile a template string into a render function code string.

Note: This function is for advanced use cases where you need the generated code as a string.

createRenderContext(options)

hasTemplateSyntax(template)

Check if a template string contains template syntax.

RENDER_CONTEXT_KEYS

  • Type: array
  • Default: ["htmlspecialchars","setCookie","redirect","$REQUEST","$METHOD","$URL","$HEADERS","$COOKIES","$RESPONSE"]

renderToResponse(htmlTemplate, opts)

Renders an HTML template to a Response object.

Example:

import { compileTemplate, renderToResponse } from "rendu";

const render = compileTemplate(template, { stream: true });

const response = await renderToResponse(render, { request });

Syntax

Rendu uses PHP-style tags to embed JavaScript within HTML templates:

Server Scripts

Use <script server> to execute JavaScript on the server where it appears:

<script server>
  globalThis.visitedPagesCount ??= 0;
  globalThis.visitedPagesCount++;
</script>

Output Expressions

Use {{ expression }} for HTML-escaped output, or {{{ expression }}} or <?= expression ?> for unescaped (raw) output:

<h1><?= title ?></h1>
<div>Page visited: {{ visitedPagesCount }}</div>

Control Structures

Use <? ... ?> for JavaScript control flow:

<? if (items.length === 0) { ?>
<p>No items found.</p>
<? } ?> <? for (const item of items) { ?>
<li>{{ item.name }}</li>
<? } ?>

Streaming Content

Use the echo() function for streaming content. Accepts: strings, functions, Promises, Response objects, or ReadableStreams:

Examples:

<!-- Simple string output -->
<script server>
  echo("Welcome to our site!");
</script>

<!-- Async content from API (non-blocking)-->
<script server>
  echo("Hello");
  echo(async () => fetch("https://api.example.com/data"));
  echo(() => "World");
</script>

Global Variables

Access request context and global state:

  • $REQUEST: The incoming Request object
  • $METHOD: HTTP method (GET, POST, etc.)
  • $URL: Request URL object
  • $HEADERS: Request headers
  • $RESPONSE: Response configuration object
  • $COOKIES: Read-only object containing request cookies

Cookie Management

Use setCookie() function to set cookies in the response:

<script server>
  setCookie("user", "RenduUser");
  setCookie("session", "abc123", { maxAge: 3600, httpOnly: true });
</script>

Access cookies from the request using $COOKIES:

<div>Welcome, <?= $COOKIES["user"] || "Guest" ?>!</div>

Response Control

Use redirect() function to redirect the user:

<script server>
  if (!$COOKIES["auth"]) {
    redirect("/login");
  }
</script>

HTML Escaping

The htmlspecialchars() function is available for escaping HTML content:

[!TIP] When using curly {{ }} syntax, htmlspecialchars will be automatically applied.

<div><?= htmlspecialchars(userInput) ?></div>

Development

  • Clone this repository
  • Install the latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

Prior Art

License

Published under the MIT license.