Gravity
p/gravity-9
The scalable RPC framework
Matthieu Gindre
Gravity — A modern RPC framework for Svelte, React, Solid and Vue
Featured
18
Gravity allows you to call functions defined in your server directly in your client. It is a modern back-end framework that can integrate with your front-end like Svelte, React, Solid and Vue.
Replies
Gary Fung
This looks like https://blitzjs.com
Matthieu Gindre
@garyfung Indeed, both aim to greatly ease the server / client communication. I was excited when I first discovered Blitz until I realized it could be even more simplified. Differences between Gravity and Blitz : - Gravity handles authorization in a declarative way (with decorators and constraints) where blitz is imperative. - You don’t have to use Zod with Gravity because the framework will reuse your Typescript types for validation. That results in a very clean code. - Blitz is an alternative to Next. Gravity is much more flexible and can be used on top of Next, Nuxt, SvelteKit, Express, or a vanilla Node server. - Blitz is only compatible with React. Gravity is also compatible with Svelte, Solid and Vue. (I’m using it with Svelte).
Gopalakrishna Palem
One of the reasons the backend is split is for scalability (of servers). How does it work when the front-end is tightly coupled with back-end server? Can the servers be scaled independent of front-end on demand?
Matthieu Gindre
@gpalem You can freely use Gravity with a split backend / frontend as well. That’s what I’m actually doing in the SAAS I’m working on. I have a monorepo architecture with client and server sharing types and communicating via Gravity. Gravity can also integrate with a full-stack framework like SvelteKit, Next or Nuxt. In that case indeed, backend and frontend are united as one application. Scaling that kind of application will only scale backend - the frontend is independant of all scaling since it is handled by the browser.
Richie
This looks oddly similar to useGravity.app by Kyle Gawley. Similar niche, same name, pretty much the same logo... interesting!
Matthieu Gindre
@richiemcilroy I just realised that thanks to your comments 😅 The logo looks very much the same, it’s confusing. The two frameworks can look similar at first but they are actually very different. usegravity.app: - is a boilerplate for a Node.js & React app. It means is just a template with a lot of stuff preinstalled, and you can only use it when you have a Node server and a React frontend. - you must pay for it - comes with a lot of stuff like Stripe integration, analytics dashboard, socials integration, database connection, pre-made ui components - use a standard REST api to communicate between client and server Gravity by Digital loukoums: - is a lower-level framework to help communicating between a server and a client both written in Typescript (you can use Javascrit as well but that’s not recommended) - is open-source and free - integrates very well with other frameworks like React, Next, Svelte & SvelteKit, Vue, Nuxt, SolidJS, and Prisma - can be used upon a Node server but also a SvelteKit or Next server - which means it’s compatible with serverless and edge functions - will provide you a end-to-end safe way to call your server functions from your client. (You can see Gravity as a SDK-on-demand.)
Ahmet Bayhan BAYRAMOĞLU
Hello, I like the architecture and idea behind the product. Because I see myself predominantly as a Frontend developer, I might consider Gravity in one project instead of NestJS\Vue two separate projects. However, there will be a problem. Will we have compatibility problems with frequently used backend tools such as Redis or Elasticsearch etc. and popular npm backend libraries? Finally, the "previous" and "next" buttons on your documentation pages do not work (for mobile). Congratulations and good luck.
Matthieu Gindre
@deficiency Yep, I’m using a library for the documentation and the « next » and « previous » buttons are a bit confusing. You actually have to click the page name rather than « next ». You can actually use Gravity as a total replacement of Nest and keep your two projects Gravity/Vue separate. That’s what I’m doing in the SAAS I’m working on (Gravity server and Svelte frontend). In that case, a Gravity server will work exactly like a Nest server and can be used with Redis, ElasticSearch, and any other tool. The only constraint is that you have to keep your two projects in the same monorepo so that you can share types between the server and the client. The services architecture of Gravity is inspired by Nest - but without all the boilerplate -, so I guess you will easily find your marks.
John Ladaga
How does this differ from useGravity.app? Genuinely curious.
Matthieu Gindre
@askproxii Wow I didn’t know there is another framework called « usegravity » that doesn’t look so different at first 😅 But actually the two « Gravities » are different tools that have nothing in common. usegravity.app: - is a boilerplate for a Node.js & React app. It means is just a template with a lot of stuff preinstalled, and you can only use it when you have a Node server and a React frontend. - you must pay for it - comes with a lot of stuff like Stripe integration, analytics dashboard, socials integration, database connection, pre-made ui components - use a standard REST api Gravity by Digital loukoums: - is a lower-level framework to help communicating between a server and a client both written in Typescript (you can use Javascrit as well but that’s not recommended) - is open-source and free - integrates very well with other frameworks like React, Next, Svelte & SvelteKit, Vue, Nuxt, SolidJS, and Prisma - can be used upon a Node server but also a SvelteKit or Next server - which means it’s compatible with serverless and edge functions - will provide you a end-to-end safe way to call your server functions from your client. Classic REST apis are too hazardous. You can see Gravity as a SDK-on-demand.
Basharath
Congrats on the launch. It looks great.
Slava Knyazev
What does the schema look like when it’s generated? I’m just wondering how tightly it couples the frontend to the backend.
Matthieu Gindre
@vezaynk it actually couples tighter than necessary. The only information needed by the server to perform parameters validation is the types of the parameters. The schema holds more information like the return type of the functions, the types of the non-function exposed properties, the modifiers (async, readonly, private, etc…). You can be sure that the typescript type is the actual type of the data you receive. It even works for generics and template literals. Gravity uses Typezer to create the schema, and right now there is only one known caveat documented here : https://github.com/digital-louko... It’s when you do a **circular generic**, which is a quite complex type form very unlikely to happen.
Claudio Silva
Launching soon!
This looks promising!
Aakash Pal
good
Matthieu Gindre
I started to work on Gravity because I was frustrated by the Nest + GraphQL + Apollo architecture that we used on my previous company. It was so boilerplatey and unnecessary complicated to exchange data between the client and the server. Gravity closes this server/client gap by bringing to the client the capacity to call functions defined server-side… like it’s just a normal Javascript function. No need to learn a query language like GraphQL. No more 100% unsafe REST apis. I aimed to bring simplicity and safety to full-stack development, along with a very enjoyable developer experience. I’m using Gravity for the SAAS I’m working on full-time (a modern writing software for literature) and I’m having a great time with it. I hope you will like it as much as I do. Every comment and idea of future development is very welcome 😉
Matthieu Gindre