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

tradie-template-react-static-site

v6.1.0-alpha.bdb7e882

Published

Tradie template for building static sites with React.

Downloads

28

Readme

tradie-template-react-static-site

Tradie template for building static sites with React.

Installation

npm install --save-dev tradie tradie-template-react-static-site

Usage

Creating the layout

The layout defines the template which each page is rendered into.

The the layout may exist anywhere within the ./src directory. You will need to tell tradie which directory the layout lives in:

./src/site.json

{
  "layout": "./layout"
}

The layout directory must contain a index.jsx file. It should export two properties:

  • getProps - Optional. A function that returns a Promise. Used to fetch any data required by the layout component.
  • default - Required. A React.Component. Used to render the page into, usually including the <head/>, <body/> and any other components common to every page page.

The layout component will receive the following props:

  • root - A string. The path of the root directory.
  • styles - An array of strings. A list of style bundles extracted from the layout module and/or the page module.
  • scripts - An array of strings. A list of script bundles used by the layout module and/or the page module.
  • children - A node.
  • ... - Any other props returned by getProps().
Styles

Any styles imported by the module (e.g. import './index.css';) will be extracted as an external CSS file.

Scripts

The layout directory may contain a script.js file. This file and its dependencies will be transpiled and bundled for use on the client. Styles imported in this file will not be extracted and will remain in the JS bundle.

Example

./src/layout/index.jsx

import React from 'react';

export default ({root, styles, scripts, children}) => (
  <html>
    <head>
      <meta charSet="utf-8"/>
      {styles.map(
        style => <link key={style} rel="stylesheet" href={style}/>
      )}
    </head>
    <body>
      <header>
        <a href={root}>&#127968;</a>
      </header>
      {children}
      {scripts.map(
        script => <script key={script} src={script} defer/>
      )}
    </body>
  </html>
);

Creating a page

A page defines the content of each page.

The the page may exist anywhere within the ./src directory. You will need to tell tradie which directory the page lives in and where the rendered page should be output:

./src/site.json

{
  "pages": [
    "./pages/HelloWorld"
  ]
}

The page directory must contain a index.jsx file. It should export three properties:

  • getProps - Optional. A function that returns a Promise. Used to fetch any data required by the page component e.g. product information, product prices etc. May return an array if the page should be rendered multiple times.
  • getPath - Required. A function that returns a string. Used to get the path of the rendered file. Will be called multiple times if getProps() returns an array.
  • default - Required. A React.Component. Used to render the page.

A page component will receive the following props:

  • root - A string.
  • ... - Any other props returned by getProps().
Styles

Any styles imported by the module (e.g. import './index.css';) will be extracted as an external CSS file.

Scripts

The page directory may contain a script.js file. This file and its dependencies will be transpiled and bundled for use on the client. Styles imported in this file will not be extracted and will remain in the JS bundle.

Example

./src/pages/HelloWorld/index.jsx


export default () => (
  <div>
    <h1>Hello world!</h1>
  </div>
);

Commands

tradie build

Will lint, transpile, bundle and render your pages into the ./dist directory.

tradie build --watch

Will lint, transpile, bundle and render your pages into the ./dist directory whenever a source file changes.

tradie build --optimize

Will lint, transpile, bundle, minify and render your pages into the ./dist directory.

tradie serve

Will lint, transpile, bundle and render your pages into the ./dist directory, and serve the directory at http://localhost:3000.

tradie test

Will lint, transpile, bundle and run your *.test.{js,jsx} files.

tradie test --watch

Will lint, transpile, bundle and run your *.test.{js,jsx} files whenever a source file changes.