Skip to main content
MetaPoint

MetaPoint

⚡Meta first and low-code. Peer-to-Peer typesafe APIs or Channels made easy.

Guide 💡⭐ Star

⚡Efficient

HTTP frequent connections waste your time? MetaPoint connect only once, communicate unlimited times.

🤝Bidirectional channel

MetaPoint establish a bidirectional channel between devices, so that you no longer have to worry about server-side push.

🪞Shadow functions

Call APIs painlessly, just like using local functions(Even includes error catching).

👌Autocompletion

Just like calling native functions, TypeScript gives you autocompletion across devices!

🎡Run everywhere

Nodejs and Browser? Metapoint can all run!

🪐P2P or C/S

Whether there is a centralized server or not, you have the final say.

🔢Data codec agnostic

JSON, Protobuff, xml, Thrift, MessagePack ...

📡Transport protocol agnostic

tcp, ws, webtransport, quic...

🔒Automatic typesafety

Something changed? TypeScript will warn you of errors before you even save the file.

⚙Auto management

Streams are managed by MetaPoint. You only need to consider the business code!

🔐Secure transmission

Devices communicate with each other over encrypted channels.

🧩Plugin support

Extend MetaPoint through plugins.

❓️What's MetaPoint?

Demo

MetaPoint lets you focus on what you want to do

  • You no longer need to pay attention to tedious network layer coding, just write business code. Save a lot of time and energy.

  • MetaPoint works well with nodejs and any front-end framework.

  • MetaPoint saves your team a lot of communication time because the SDK is automatically generated. API documentation is also no longer needed.

  • You will never get your API called incorrectly. TypeScript will warn you of errors in the call before you even save the file.

  • Thanks to the extensibility of libp2p, you can use any transport protocol, including any in the future, which means zero upgrade cost.

  • MetaPoint is great for making real-time applications.

  • MetaPoint is great for making client-first apps.

  • Using metapoints makes your app to be more immune to malicious crawlers.

  • Metapoint's secure transmission protects you from man-in-the-middle attacks.

🛠Install

Install MetaPoint:

pnpm
pnpm add metapoint

🚀Usage

👉 Define endpoints

// server.ts
import { h, MetaType, peer, z } from "metapoint";

const group = h({ context: { addnum: 1 } });

const endpoint = {
  add: group.handler({
    func: async ({ data, send, done, context }) => {
      await send(data + context.addnum);
      await done();
    },
    input: z.number(),
    output: z.number(),
  }),
};

const node = await peer({ endpoint });
export type Meta = MetaType<typeof node>;

console.log("MetaPoint addr: ", node.meta().addrs);
// /ipv4/127.0.0.1/xxxxxx (it's your server's connect addr)






 
 
 
 
 
 
 
 







👉 Call endpoints

// client.ts
import { peer } from "metapoint";
import type { Meta } from "./server";
const node = await peer();
const channel = await node.connect<Meta>("your server addr");
const add = await channel("add");
console.log(await add(1)); // [2]





 
 

🎉Try it out for yourself!