# Examples (https://effetch.pages.dev/docs/examples)

The guides show one feature at a time. When you want to see several of them
working together in a whole program, look in the repository's
[`examples/`](https://github.com/monarcode/effetch/tree/main/examples)
folder.

The examples are typechecked with the package on the `main` branch, which
can be ahead of the latest release. To read them as they were at your
version, switch GitHub's branch menu to that release's tag, such as
`v0.1.0-rc.4`.

The folder has these programs:

- [`basic.ts`](https://github.com/monarcode/effetch/blob/main/examples/basic.ts):
  a client in a service, the methods, and handling each error.
- [`builtins.ts`](https://github.com/monarcode/effetch/blob/main/examples/builtins.ts):
  the built-in plugins, and changing them for one call.
- [`plugins.ts`](https://github.com/monarcode/effetch/blob/main/examples/plugins.ts):
  writing plugins, from auth with a service to a `wrap` with its own error.
- [`endpoints.ts`](https://github.com/monarcode/effetch/blob/main/examples/endpoints.ts):
  the same app as `builtins.ts`, with endpoints.
- [`backends.ts`](https://github.com/monarcode/effetch/blob/main/examples/backends.ts):
  two backends in one file, with shared plugins.
- [`status-errors.ts`](https://github.com/monarcode/effetch/blob/main/examples/status-errors.ts):
  your own errors by status, for every call, per endpoint and for one call.
- [`streams.ts`](https://github.com/monarcode/effetch/blob/main/examples/streams.ts):
  Server-Sent Events, newline-delimited JSON, and a list paged through by its
  `Link` header.
- [`testing.ts`](https://github.com/monarcode/effetch/blob/main/examples/testing.ts):
  tests for the `app/` todos module, against a fake backend made from its
  endpoints.
- [`app/`](https://github.com/monarcode/effetch/tree/main/examples/app): a
  feature-sliced app, with clients as shared infrastructure and each module
  defining its own endpoints.

The examples'
[README](https://github.com/monarcode/effetch/blob/main/examples/README.md)
walks through each one, and explains how `app/` is laid out.

## What's next

- [Structure an app](https://effetch.pages.dev/docs/structuring-an-app): see the layout that `app/`
  follows, and when to use it.
- [Test with a fake backend](https://effetch.pages.dev/docs/testing): write tests like the ones in
  `testing.ts`.