Prev

Prev is small something.

something, because it's hard to categorise it has a library or a framework or even a boilerplate though it picks up things from all 3.

The primary usecase was to be a demo for fresh.deno.dev to adopt preact-island-plugins but, since fresh has moved way past experimentation phase it'd be a hard sell. Either way, we shifted the focus and tried to build a boiler plate that could help you write full stack components using preact and islands.

Note: Islands are components that are interactive. You can read more about why they are called islands from https://jasonformat.com/islands-architecture and A short introduction to Islands

To get you interested in prev, here's what a page would look like in prev

// -- pages/index.js

// Respond to GET on /
export const get = (ctx) => {
  const greeting = await someAsyncAction()
  return <h1>{greeting}</h1>;
};

// Respond to POST on /
export const post = (ctx) => {
  ctx.writeHead(200, {
    "Content-Type": "application/json",
  });
  return ctx.res.end(
    JSON.stringify({
      success: "true",
    })
  );
};

If it looks backend focused, you'd be right, prev makes it easier to write both REST API routes and handle rendering of islands for you. You just need to return either a view (preact based JSX) or respond to it like you'd respond to a REST request or do whatever else you'd do with a network request.

If all this sounds fun and interesting, let's go to the [01-getting-started] section.