Skip to main content
Home

Built and signed on GitHub Actions

Fns is the React for backend development, making serverless functions invincible. It offers a zero-infrastructure platform with reliable execution, signal handling, all with built-in observability.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
76%
Published
a year ago (0.2.0)

Fns Screenshot

About

Website - Discord - Documentation

⚠ Warning
Fns is currently in the early stages of development and is not yet ready for daily use. Please do not use it in production environments.

Fns SDK is a serverless stateless durable function design pattern. Works with any framework and platform.

Key Features

  • Infinite Loop: Run durable function for an infinite amount of time with auto snapshot.
  • Scalability: Scale your durable function to infinity, the only limit is your provider.
  • Serverless: No need to manage servers or infrastructure.
  • Signals & Queries: Trigger signals or query to other functions.
  • Mutexes: Solve race conditions at scale with intuitively.
  • Awaitable: Await for the result of a function or signal.

Example

fns.createFunction(
  { name: "helloworld", version: 1 },
  ({ useState, useSignal }) => {
    const [name, setName] = useState<string>("name", "John Travolta");
    useSignal<string>("setName", (newName) => setName(newName));

    return async ({ step }) => {
      const firstName = await step.run(
        "set-firstname",
        async () =>
          await fetch("https://api.namefake.com/")
            .then((res) => res.json())
            .then((res) => res.name),
      );
      await step.sleep("wait-10s-then-finish", "5s");
      const lastName = await step.run(
        "set-lastname-Fernandes",
        async () =>
          await fetch("https://api.namefake.com/")
            .then((res) => res.json())
            .then((res) => res.name),
      );

      return `Hello ${firstName} ${lastName}`;
    };
  },
);
fns.createFunction(
  { name: "LockerBox", version: 1 },
  ({ useSignal, useQuery, useState }) => {
    const [locked, setLocked] = useState<boolean>("isLocked", true);
    useSignal("unlock", () => setLocked(false));
    useQuery("isLocked", () => locked());
    return async ({ step, ctx }) => {
      const data = ctx.data as { isLocked: boolean };
      if (data && data.isLocked !== undefined) {
        setLocked(data.isLocked);
      }
      await step.condition("wait-unlock", () => locked() === false);
      return "unlocked";
    };
  },
);

License

MIT License

The Fns SDK and its integrations are licensed under the Apache-2 License.

The full text of the license can be accessed via this link and is also included in the LICENSE.md file of this software package.

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@fns-run/fns

Import symbol

import * as fns from "@fns-run/fns";
or

Import directly with a jsr specifier

import * as fns from "jsr:@fns-run/fns";

Add Package

pnpm i jsr:@fns-run/fns
or (using pnpm 10.8 or older)
pnpm dlx jsr add @fns-run/fns

Import symbol

import * as fns from "@fns-run/fns";

Add Package

yarn add jsr:@fns-run/fns
or (using Yarn 4.8 or older)
yarn dlx jsr add @fns-run/fns

Import symbol

import * as fns from "@fns-run/fns";

Add Package

vlt install jsr:@fns-run/fns

Import symbol

import * as fns from "@fns-run/fns";

Add Package

npx jsr add @fns-run/fns

Import symbol

import * as fns from "@fns-run/fns";

Add Package

bunx jsr add @fns-run/fns

Import symbol

import * as fns from "@fns-run/fns";