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.
@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).
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?
@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.
@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.)
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.
@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.
@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.
@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.
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 😉