Elysia Intro
Elysia Intro
Elysia Intro
- - meta
- name: 'description'
content: ElysiaJS is a fast and friendly bun web framework. Building on top
of 3 philosophies, performance, simplicity, flexibility. Designed with TypeScript
in mind. Elysia understands what you want and automatically infers the type from
your code.
- - meta
- property: 'og:description'
content: ElysiaJS is a fast and friendly bun web framework. Building on top
of 3 philosophies, performance, simplicity, flexibility. Designed with TypeScript
in mind. Elysia understands what you want and automatically infers the type from
your code.
---
# Introduction
ElysiaJS is a fast, and friendly [Bun](https://bun.sh) web framework.
Designed with TypeScript in mind, you don't need to understand TypeScript to take
advantage of Elysia. The library understands what you want and automatically infers
the type from your code.
---
You can define a custom type for many things, for example, an incoming request's
body.
```typescript
import { Elysia, t } from 'elysia'
new Elysia()
.post('/sign-in', ({ body }) => signIn(body), {
body: t.Object({
username: t.String(),
password: t.String()
})
})
.listen(8080)
```
You explicitly tell Elysia that the incoming request body is expected to have a
structure as you define it.
Elysia then infers the type from the code you write. Validate the body from the
incoming request to ensure the type safety.
new Elysia()
/* [!code ++] */ .use(swagger())
.post('/sign-in', ({ body }) => signIn(body), {
body: t.Object({
username: t.String(),
password: t.String()
})
})
.listen(8080)
```
And finally, you can create a fully type-safe client for consuming Elysia API with
Eden (optional).
```typescript
// server.ts
import { Elysia, t } from 'elysia'
import { swagger } from '@elysiajs/swagger'
app.signIn.post({
username: 'saltyaom',
password: 12345678
}).then(console.log)
```
Creating a single source of truth for your data structure, eliminating any possible
type conflict between TypeScript, actual requests via validation, API
documentation, and frontend client.