Eden Treaty represents your Elysia server as a tree of JavaScript objects that mirror the server’s URL structure. Each segment of a URL path becomes a property, and each HTTP method becomes a callable function at the leaf. TypeScript infers the correct parameter and response types for every call automatically.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/elysiajs/documentation/llms.txt
Use this file to discover all available pages before exploring further.
Basic usage
Export your server type, then pass it totreaty along with your server’s address:
Tree-like path syntax
HTTP paths are hierarchical — each/ separates a level. Eden Treaty translates that hierarchy into JavaScript dot notation.
| Path | Treaty call |
|---|---|
/ | .get() |
/hi | .hi.get() |
/deep/nested | .deep.nested.get() |
| Path | Method | Treaty call |
|---|---|---|
/ | GET | .get() |
/hi | GET | .hi.get() |
/deep/nested | GET | .deep.nested.get() |
/deep/nested | POST | .deep.nested.post() |
Dynamic path parameters
Static dot notation can’t express named parameters like/item/:name. Instead, call the segment as a function and pass an object with the parameter name as the key:
| Path | Treaty call |
|---|---|
/item | .item |
/item/:name | .item({ name: 'Skadi' }) |
/item/:name/id | .item({ name: 'Skadi' }).id |
Supported HTTP methods
Treaty exposes a method function for each standard HTTP verb:| Method | Treaty call |
|---|---|
| GET | .get() |
| POST | .post() |
| PUT | .put() |
| PATCH | .patch() |
| DELETE | .delete() |
| HEAD | .head() |
| OPTIONS | .options() |
Next steps
Parameters
Learn how to pass body, query params, headers, and file uploads.
Responses
Handle typed responses, errors, and status code discrimination.