Back to Blitz

README

packages/blitz-rpc/README.md

3.0.23.9 KB
Original Source

<!-- prettier-ignore-start --> <p align="center"> <a aria-label="Join our Discord Community" href="https://discord.blitzjs.com"> </a> <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> <a aria-label="All Contributors" href="#contributors-"></a> <!-- ALL-CONTRIBUTORS-BADGE:END --> <a aria-label="License" href="https://github.com/blitz-js/blitz/blob/main/LICENSE"> </a> <a aria-label="NPM version" href="https://www.npmjs.com/package/@blitzjs/auth"> </a> </p> <!-- prettier-ignore-end --> <h1 align="center"> Blitz "Zero-API" data layer (Blitz RPC) </h1>

Quick Start

Install Blitz RPC

bash
`npm i @blitzjs/rpc`
# yarn add @blitzjs/rpc
# pnpm add @blitzjs/rpc

You can alternatively use npx

Overview

Blitz "Zero-API" data layer (Blitz RPC) is focused on making the communication between server and client seamless. It lets you

import server code directly into your components instead of having to manually add API endpoints and do client-side fetching and caching. Here's a quick overview:

Queries and mutations

Queries and mutations only run on the server — at build time, the direct function import is replaced with an RPC network call. So the query function code is never included in your client code. It's instead moved to an API layer.

Framework Support

Currently Blitz RPC is only supported in Next.js. We are working on adding support for other frameworks.

Setup Blitz RPC in Next.js