Installation
Add Effetch to a project and import its entry points.
Effetch is one package, and the only other package it needs is Effect. This page shows how to add both to your project and how to import Effetch, so you're ready to write your first call.
Before you begin
You need:
- an ESM project, such as one with
"type": "module"in itspackage.json, since the package is ESM only; - TypeScript 5.7 or later;
- a supported runtime. Compatibility lists them, and which of them CI tests.
effect 4.x is a peer dependency: you install it next to Effetch, in the
next step.
Install the package
To install Effetch and Effect, run the command for your package manager:
- npm:
npm install @monarcode/effetch effect - pnpm:
pnpm add @monarcode/effetch effect - Yarn:
yarn add @monarcode/effetch effect - Bun:
bun add @monarcode/effetch effect
An Expo or React Native project uses the same command.
Import Effetch
Everything in the main entry is under one export, Fetch. The plugins and
the test backend each have an entry of their own:
import { } from "@monarcode/effetch";
import { , } from "@monarcode/effetch/plugins";
import { } from "@monarcode/effetch/test";
export const = [({ : "token" }), ()];
export const = .("GET /todos/:id");
export const = .([]);Your editor offers to add the Fetch import as you type the name. When you
need only its types, write import type { Fetch } from "@monarcode/effetch".
The package has two more entries, @monarcode/effetch/Fetch and
@monarcode/effetch/test/FetchTest. They hold the same exports without the
namespace, the way effect/Effect relates to import { Effect } from "effect". TypeScript uses them to name Effetch's types in the .d.ts files
it emits for your code. In your own code, import from the main entry.
If your project was written for 0.1.0-rc.3 or earlier, its imports need to
move to Fetch. See Upgrade from 0.1.0-rc.3.
What's next
- Getting started: write a first program that makes a typed call, and run it.
- Coming from axios or ky: see how what you know from those libraries maps to Effetch.