Is anybody else in here super hyped on Elysia

Just putting out feelers for this. The second I tried out Elysia months ago my immediate thought was "Holy shit this is cool", and I feel like I haven't seen much hype around it here and am kind of surprised by that. To be clear, if you choose to keep reading this has almost nothing to do with the fact that: • Bun is cool bun Elysia is fast <:elysia_love:1140316901973708850> But instead, here's why I think it might be something worth paying attention to from this community, which I originally became a part of because of the focus on efficient full-stack workflow through create-t3: 1. The typesafety is <:chef_kiss:1101121096318713866> Right off the bat as a backend framework it's easily, and by far the best typescript experience I've had in a javascript backend. 2. You can generate a trpc-like client by injecting the typeof app into something called an edenTreaty The thing I like about this client way more than trpc so far, is with your backend just build some REST style endpoints, then you can build a client like this... [read more here https://elysiajs.com/plugins/eden/treaty.html], which to me reminds me a lot of the talk that @theo gave a while back about graphQL and how trpc is like a tradeoff that locks you into the typescript ecosystem. Well this does not do that., because even if you can't use an eden treaty, you still have a REST architecture.
const app = edenTreaty<App>('http://localhost:8080')
const { data: nendoroid, error } = app.mirror.post({
id: 1895,
name: 'Skadi'
})
const app = edenTreaty<App>('http://localhost:8080')
const { data: nendoroid, error } = app.mirror.post({
id: 1895,
name: 'Skadi'
})
3. Given the above points, it feels like this backend framework has the capability of filling in many pieces to the puzzle of "How do I get fullstack typesafety, without feeling like I don't have a proper backend", which to me is what NextJS, Remix, SolidStart, SvelteKit all feel like they fail at on some level to me personally. I think that it also has the potential to calm down a lot of the fears around "If I build this app with a full stack framework, will it be a PITA to decouple the code later on if I need to for some reason?" For example imagine if you had a backend that looked like this
const dogs = ["doomslayer", "zoey", "bowser"]
const app = new Elysia()
.get("dogs", () => dogs)
.post("dogs", ({body: dog}) => {
dogs.push(dog)
}, {body: T.String()})
const dogs = ["doomslayer", "zoey", "bowser"]
const app = new Elysia()
.get("dogs", () => dogs)
.post("dogs", ({body: dog}) => {
dogs.push(dog)
}, {body: T.String()})
I'll use remix as an example here just because I know it better, you could do something like
const loader = () => {
return {
dogs: (await eden.dogs.get()).data
}
}

const page = () => {
const { dogs } = await useLoaderData<typeof loader>()
const revalidator = useRevalidator()

return (
<>
<DogsList dogs={dogs} />
<CreateDogForm createDogFn={(newDog) => {
// since this is just a thin wrapper around
// fetch it works perfect both server and client side
eden.dogs.post(newDog)
.then(() => revalidator.revalidate())
}} />
</>
)

}
const loader = () => {
return {
dogs: (await eden.dogs.get()).data
}
}

const page = () => {
const { dogs } = await useLoaderData<typeof loader>()
const revalidator = useRevalidator()

return (
<>
<DogsList dogs={dogs} />
<CreateDogForm createDogFn={(newDog) => {
// since this is just a thin wrapper around
// fetch it works perfect both server and client side
eden.dogs.post(newDog)
.then(() => revalidator.revalidate())
}} />
</>
)

}
1 Reply
Want results from more Discord servers?
Add your server