Skip to content

gRPC zig

Blazigly fast gRPC/MCP client & server implementation in zig

Install

$git clone https://github.com/ziglana/gRPC-zig

Install command taken from the project's README or registry entry. Always review code before running it.

🚀 gRPC-zig

A blazingly fast gRPC client & server implementation in Zig, designed for maximum performance and minimal overhead.

⚡️ Features

  • 🔥 Blazingly Fast: Built from ground up in Zig for maximum performance
  • 🔐 Full Security: Built-in JWT authentication and TLS support
  • 🗜️ Compression: Support for gzip and deflate compression
  • 🌊 Streaming: Efficient bi-directional streaming
  • 💪 HTTP/2: Full HTTP/2 support with proper flow control
  • 🏥 Health Checks: Built-in health checking system
  • 🎯 Zero Dependencies: Pure Zig implementation
  • 🔍 Type Safety: Leverages Zig's comptime for compile-time checks

🚀 Quick Start

const std = @import("std");
const GrpcServer = @import("grpc-server").GrpcServer;

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();
    const allocator = gpa.allocator();

    // Create and configure server
    var server = try GrpcServer.init(allocator, 50051, "secret-key");
    defer server.deinit();

    // Register handlers
    try server.handlers.append(allocator, .{
        .name = "SayHello",
        .handler_fn = sayHello,
    });

    // Start server
    try server.start();
}

fn sayHello(request: []const u8, allocator: std.mem.Allocator) ![]u8 {
    _ = request;
    return allocator.dupe(u8, "Hello from gRPC-zig!");
}

📚 Examples

Basic Server

See examples/basic_server.zig for a complete example.

const std = @import("std");
const GrpcServer = @import("grpc-server").GrpcServer;

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();
    const allocator = gpa.allocator();

    var server = try GrpcServer.init(allocator, 50051, "secret-key");
    defer server.deinit();

    try server.start();
}

Basic Client

See examples/basic_client.zig for a complete example.

const std = @import("std");
const GrpcClient = @import("grpc-client").GrpcClient;

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();
    const allocator = gpa.allocator();

    var client = try GrpcClient.init(allocator, "localhost", 50051);
    defer client.deinit();

    const response = try client.call("SayHello", "World", .none);
    defer allocator.free(response);

    std.debug.print("Response: {s}\n", .{response});
}

Features

All features are demonstrated in the examples/ directory:

🔧 Installation

Option 1: Using zig fetch (Recommended)

  1. Add the dependency to your project:
zig fetch --save git+https://github.com/ziglana/gRPC-zig#main
  1. Add to your build.zig:
const grpc_zig_dep = b.dependency("grpc_zig", .{
    .target = target,
    .optimize = optimize,
});

// For server development
exe.root_module.addImport("grpc-server", grpc_zig_dep.module("grpc-server"));

// For client development
exe.root_module.addImport("grpc-client", grpc_zig_dep.module("grpc-client"));
  1. Import in your code:

Similar plugs

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

Java 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype…