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

@itemconsulting/storybook-framework-enonic-xp

v0.2.0

Published

Storybook framework that renders Enonic XP FreeMarker/Thymeleaf templates server-side.

Downloads

230

Readme

Enonic XP framework for Storybook

Storybook framework for integrating with Enonic XP. It pairs the @storybook/server renderer (stories are rendered server-side by a running XP instance) with the Vite builder, and adds support for FreeMarker (.ftl, .ftlh, .ftlx) and Thymeleaf (.html) templates.

npm version

Usage

Install the package and its peer dependencies in your project.

npm i -D @itemconsulting/storybook-framework-enonic-xp storybook vite

Use it as the framework in your main.ts (or main.js) file — it is no longer an addon:

import type { StorybookConfig } from "@itemconsulting/storybook-framework-enonic-xp";

const config: StorybookConfig = {
  stories: ["../src/**/*.mdx", "../src/**/*.stories.ts"],
  framework: {
    name: "@itemconsulting/storybook-framework-enonic-xp",
    options: {},
  },
};

export default config;

Typing template imports

In a story you import a template to get its id, which the framework resolves to the template's path relative to src/main/resources:

import id from "./header.ftlh"; // id="site/parts/header/header.ftlh"
import type { Meta } from "@itemconsulting/xp-storybook-utils";

export default {
  title: "Part/Header",
  parameters: {
    server: { 
      id
    },
  },
} satisfies Meta;

To make TypeScript aware of *.ftl, *.ftlh, *.ftlx and *.html imports (typed as string), add this package to the types array under compilerOptions in your project's tsconfig.json:

{
  "compilerOptions": {
    "types": ["@itemconsulting/storybook-framework-enonic-xp"]
  }
}

Testing stories with @storybook/addon-vitest

You can run your stories as tests with @storybook/addon-vitest. Because this framework uses the @storybook/server renderer, each story renders by fetching its HTML from a running XP server — so these are server-integration tests, not isolated component tests, and your XP dev server must be running while they execute.

Install the test dependencies in your project:

npm i -D @storybook/addon-vitest vitest @vitest/browser-playwright playwright
npx playwright install chromium

The playwright install step downloads the browser you run the stories in — swap chromium for firefox or webkit if you set a different browser in defineXpStorybookProject().

To use the Coverage feature from the Storybook test panel, also install @vitest/coverage-v8 (matching your Vitest version):

npm i -D @vitest/coverage-v8

Add the addon in your main.ts:

const config: StorybookConfig = {
  addons: ["@storybook/addon-vitest"],
  // ...
};

Create a vitest.config.ts using the helper this framework ships. It reuses the framework's Vite setup (FreeMarker/Thymeleaf transform and process.env.* defines), configures Playwright browser mode, and — when you pass serverUrl — fails fast with a clear message if the XP server is down:

import { defineConfig } from "vitest/config";
import { defineXpStorybookProject } from "@itemconsulting/storybook-framework-enonic-xp/vitest";

// The async callback form works whether or not your project is ESM (`"type": "module"`).
export default defineConfig(async () => ({
  test: {
    projects: [
      await defineXpStorybookProject({
        configDir: ".storybook",
        serverUrl: "http://localhost:8080/webapp/no.item.storybook",
      }),
    ],
  },
}));

That's all that's required: @storybook/addon-vitest injects the story annotations automatically (built from your preview.ts and this framework's server-renderer annotations). If you need extra beforeAll/beforeEach logic, add an explicit .storybook/vitest.setup.ts and list it in the project's test.setupFiles, importing setProjectAnnotations from /vitest-setup:

import { beforeAll } from "vitest";
import { setProjectAnnotations } from "@itemconsulting/storybook-framework-enonic-xp/vitest-setup";
import * as preview from "./preview";

const project = setProjectAnnotations([preview]);
beforeAll(project.beforeAll);

CORS: the stories are fetched from your XP server by a browser, so that server must send Access-Control-Allow-Origin headers that allow the Vitest origin, or the fetch will be blocked.

Running tests

Unit tests can be run with the following command

npm test

Contributing

See CONTRIBUTING.md for local development and the release process.