Show HN: Single source file react apps

by sandrusoon 8/25/2024, 3:25 PMwith 1 comments

by sandrusoon 8/25/2024, 3:25 PM

Hello HN,

during past few days I was exploring concept of single source file applications where you can hide the build system.

I've cobbled together snaptail which hides nextjs build system and allows to work with just a single file.

It works great for fast prototyping or building an internal/local apps.

There is also support for API routes that can be exported via api variable.

An example:

  // myapp.tsx
  export const App = () => <div>Hello world!</div>
  export const api = [
    {
      method: "GET", path: "/api/hello",
      handler: async (req, reply) => {
        return reply.send({ hello: "world" });
      }
    }
  ];
  // shell:
  npx snaptail myapp.tsx