Alternative to REST: JavaScript Client Library gRPC web now widely available


The CNCF has announced the release of the JavaScript client library gRPC-Web, which allows web apps to communicate between gRPC services.

The JavaScript Client Library gRPC-Web (gRPC Remote Procedure Calls) is now widely available. It should enable Web applications to communicate directly between gRPC services in the backend, without having to address an HTTP server as an intermediate station. This allows developers to develop gRPC architectures for their end-to-end applications. To do this you must define the data types on the client and server side, as well as the service interfaces in a .proto file. This should provide gRPC-Web with an alternative to REST in web development.

gRPC is an open-source remote procedure call (RPC) system originally developed by Google. It uses HTTP / 2 as Transport and Protocol Buffers as Interface Description Language (IDL). It has features like authentication and bidirectional streaming. It also works across languages ​​and platforms.

The Cloud Native Computing Foundation (CNCF) further states in its announcement that gRPC Web allows users to create a “service contract” between web applications and the gRPC servers in the backend. The library uses the .proto definitions and automatically generated JavaScript. Developers can choose to use Closure Compiler JavaScript or CommonJS.

Not necessary for the development process are JSON logic and managing HTTP status codes. Compared to REST, a client protocols log buffers to a gRPC backend server, which exchanges with other backend services in the same way. On REST, the web app HTTP speaks to the REST API in the backend, which then propagates Protocol Buffers to the other services.

Comparison between gRPC and REST (Image: CNCF)

Comparison between gRPC and REST (Image: CNCF)

According to the CNCF, the end-to-end connection of gRPC also has the advantage that client libraries only need gRPC libraries and can do without the HTTP client. In addition, the coordination between front-end and back-end teams should be much easier.

The contribution of the CNCF offers a sample application as well as an outlook on the future. An integration into popular front-end frameworks such as Angular, React and Vue as well as a development of language-specific proxies are planned.


Share This:

Powered by FrontNet