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 🙏

© 2024 – Pkg Stats / Ryan Hefner

oxidizer-ssr

v1.0.7

Published

A lightweight oxidizer based framework for server side rendering.

Downloads

24

Readme

Oxidizer SSR

An Oxidizer framework for implementing Server Side Rendering.

How What & Why

Oxidizer SSR is an HTML templating framework designed to be used via the backend.

It is designed to be as lightweight and simple as possible (almost a third of the package's size comes from the license).

It works by assigning a class to a corresponding HTML Element, (ex. DIV, BUTTON, etc... ). Instances of these classes are converted to JSON, in a tree structure representing HTML. This can then be sent to the frontend, where it is parsed via the parseTree method.

Usage

Creating Components

The class components can take either 1 or 2 arguments.

  1. Fields to attach to the element
  2. A subtree of child elements

A class element can have either field and subtree arguments, or only field, or only subtree arguments.

*Subtree arguments must be an array.

import {DIV, BUTTON, P, I, B, BR} from "oxidizer-ssr";

const buttonGroup = (
    new DIV({style:"display:flex"}, [
        new BUTTON(["HELLO"]),
        new BUTTON(["WORLD"])
    ])
)

const justADiv = new DIV({className:"lonely-div"});

const formattedTaxt = new P([
    "Some normal text ", 
    new I(["with italic text "]),
    "with some more normal text ",
    new B(["with some bold text!"])
]);

These class invocations result in instances of an SSRObject, which has a singular stringify method. This converts the Object into an JSON string, which can then be delivered to the frontend.

Parsing & Rendering

parseTree returns an HTMLElement instance, with an extra render method attached to it.

The render method is used to insert the HTML Element into the DOM tree, and takes 2 arguments.

  1. An HTMLElement | String (selector) to insert into/replace.
  2. Location/method of insertion. Can either be "append", "prepend", or "replace".

Example

Backend

import {DIV, BUTTON, A} from "oxidizer-ssr";

function handler(event, context){
    
    const myComponent = (
        new DIV({className: "my-div"}, [
            new BUTTON({className: "my-button"}, [
                new A({href:"#anchor"}, [
                    "HELLO WORLD"
                ])
            ])
        ])
    );

    return {
        status: 200,
        body: myComponent.stringify()
    }
}

Fontend

import {parseTree} from "oxidizer-ssr";

const res = await fetch('...');

const myComponent = parseTree(res);

myComponent.render('#ssr-div');