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

naxtjs

v1.3.4

Published

Naxt - SSR library for server-side javascript

Downloads

11

Readme

Contributors Issues License npm VersionPRs WelcomeForks Stargazers

Contents

What is Naxtjs?

Naxtjs is a javascript lib for server rending html similar to htmx.

But Naxtjs is rather light weight and simple. let see.

Naxt follows the VJS specification

If you want support my telegram group (link below).

Installation

npm

npm i naxtjs

Examples

A basic component in Naxtjs:

import { div, h1, naxt } from "naxtjs";

function Hello(name) {
  return h1("Hello " + name, {
    className: "title",
    style: {
      color: "grey",
    },
  });
}

const html = naxt.compile(div(Hello("peter"), Hello("joe"))); // html string

app.get("/", (req, res) => {
  res.send(html);
});

client usage

<!-- Load -->
<div data-naxt-load="/home.html"></div>

In the above code, Naxtjs will immediately replace the div with the html responces from the data-naxt-load attribute.

If no html comes, nothing happens.

<!-- Onclick -->
<a
  data-naxt-event="main"
  data-naxt-link="/home.html"
  data-naxt-event-type="click"
>
  <span class="title">Home</span>
</a>

In ths above Naxtjs will replace the contents of the element with id "main" with the html responces from the href when the a tag is clicked.

If no html comes, nothing happens.

const updateMain = (type, key) => {
  // ? params =   element, href
  naxt.update(
    document.getElementById("main"),
    "/o/search/?type=" +
      type +
      "&q=" +
      document.getElementById("search").value +
      "&kq=" +
      key
  );
};

In ths above function, Naxtjs will replace the contents of the element with the html responces from the href when the fucntion is called.

If no html comes, nothing happens.

See line 5 of dist/client.min.js to see how Naxtjs handles request headers for security measures when access content from servers

Server Usage

export const LoginPage = (req, res) => {
  const html = naxt.compile(
    div(
      img({
        src: "./logo.png",
        style: { maxWidth: "100px", margin: "4rem auto" },
      }),
      h1("Login"),
      input({ placeholder: "email", id: "email" }),
      input({ placeholder: "password", id: "password" }),
      button("Login", {
        id: "login",
        style: {
          color: "black",
        },
      })
    )
  );
  res.send(html);
};

There's a difference between naxt.compile and naxt.pile

Both compiles javascript to html, but can only be used on the server, but only naxt.compile can load naxtjs to the dom. So if you are using naxt.pile on a page that has no naxtjs in the window yet, you will get errors

Getting Help and Contributing

To get help on Naxtjs, join Telegram Community.