Skip to main content

A simple barebones SSR web framework for Deno. Uses preact JSX for templating. Support for file-based routing, dynamic routes, catch-all routes, and route-groups.

This package works with Deno
This package works with Deno
JSR Score
64%
Published
3 hours ago (0.9.21)

A simple barebones SSR web framework for Deno. Uses preact JSX for templating. Support for file-based routing, dynamic routes, catch-all routes, and route-groups. Build pages using JSX components, pages, layouts, 'documents', and 'route-handlers'.

Basic usage

Examples

Example 1

import { listen, serve, router, ROUTER_DEFAULTS, type Lib } from "@neuf/neuf";
import { relative, join } from "@std/join";
import { render } from "preact-render-to-string";

const importFn: Lib.ServeOptions["importFn"] = async path => {
    const thisModuleDir = import.meta.dirname!;
    const toCwd = relative(thisModuleDir, Deno.cwd());
    const fullPath = join(toCwd, path);
    return await import(fullPath);
};

listen({
    hostname: "0.0.0.0",
    port: 8080,
    handler: (req, res, isError) => {
        return serve(req, res, {
            isError,
            isNotFound: false,
            staticOptions: { fsRoot: "src/public", quiet: true },
            importFn,
            router: $req => router($req, ROUTER_DEFAULTS),
            renderJSX: render,
        });
    },
});

Add Package

deno add jsr:@neuf/neuf

Import symbol

import * as neuf from "@neuf/neuf";

---- OR ----

Import directly with a jsr specifier

import * as neuf from "jsr:@neuf/neuf";