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

@formatr/nextjs

v0.1.0

Published

Next.js integration for formatr template engine with SSR support

Readme

@formatr/nextjs

Next.js integration for formatr template engine with SSR/SSG support.

Installation

npm install @formatr/nextjs @timur_manjosov/formatr next react

Usage

Configuration

// next.config.js
import { withFormatr } from '@formatr/nextjs';

export default withFormatr({
  formatr: {
    templatesDir: './templates',
    cache: true,
    precompile: true,
  },
});

Server-Side Rendering (App Router)

// app/blog/[slug]/page.tsx
import { configureFormatr, formatr } from '@formatr/nextjs';

// Configure once (e.g., in layout or middleware)
configureFormatr({
  templatesDir: './templates',
  cache: true,
});

export default async function BlogPost({ params }: { params: { slug: string } }) {
  const post = await getPost(params.slug);
  
  const content = await formatr('blog-post', {
    title: post.title,
    author: post.author,
    content: post.content,
  });
  
  return <div dangerouslySetInnerHTML={{ __html: content }} />;
}

Server-Side Rendering (Pages Router)

// pages/posts/[id].tsx
import { GetServerSideProps } from 'next';
import { configureFormatr, formatr } from '@formatr/nextjs';

configureFormatr({
  templatesDir: './templates',
  cache: true,
});

export const getServerSideProps: GetServerSideProps = async ({ params }) => {
  const post = await getPost(params?.id as string);
  
  const content = await formatr('post', {
    title: post.title,
    body: post.body,
  });
  
  return { props: { content } };
};

export default function Post({ content }: { content: string }) {
  return <div>{content}</div>;
}

Static Site Generation

export const getStaticProps = async () => {
  const content = await formatr('homepage', {
    title: 'Welcome',
    description: 'Static content',
  });
  
  return { props: { content } };
};

Client-Side Hook

'use client';

import { useFormatr } from '@formatr/nextjs';

export function ClientGreeting({ name }: { name: string }) {
  const message = useFormatr('Hello, {name}!', { name });
  return <div>{message}</div>;
}

Async Rendering

import { formatrAsync } from '@formatr/nextjs';

export default async function UserProfile({ userId }: { userId: string }) {
  const content = await formatrAsync('user-profile', {
    userId,
  });
  
  return <div>{content}</div>;
}

API

withFormatr(nextConfig)

Next.js configuration wrapper.

Options:

  • formatr.templatesDir: Template directory
  • formatr.cache: Enable caching
  • formatr.precompile: Precompile templates at build time (future)

configureFormatr(options)

Configure formatr for server-side use.

Options:

  • templatesDir (required): Template directory
  • cache: Enable caching
  • filters: Custom filters

formatr(templateName, context)

Render template on server (SSR/SSG).

formatrAsync(templateName, context)

Render template with async filter support.

useFormatr(template, context, filters?)

Client-side hook for template rendering.

License

MIT