Migrating from gRPC-Web to connect-web
Bareun's web client has moved from the earlier gRPC-Web to connect-web.
connect-web is a lightweight RPC client that lets a browser call the Bareun server directly
without a separate proxy.
This document summarizes what changes when you move a web frontend from gRPC-Web to connect-web.
bareunpy 2.0 coming soon
This document covers the move of the web (JavaScript) client to connect-web.
A Connect-RPC-based bareunpy 2.0 for the Python client will also be available soon.
Once released, Python too becomes simpler, calling the Bareun server directly without a separate proxy.
Why migrate
The Bareun server is implemented with connect-go, so it accepts Connect-RPC, gRPC, and REST at the same time.
In a browser, you can combine @connectrpc/connect, @connectrpc/connect-web, and @bufbuild/protobuf
to call it cleanly with the standard fetch.
| Item | gRPC-Web (before) | connect-web (now) |
|---|---|---|
| Client package | grpc-web | @connectrpc/connect, @connectrpc/connect-web |
| Message package | google-protobuf | @bufbuild/protobuf |
| Transport | gRPC-Web framing | HTTP/1.1 and HTTP/2 (Connect) |
| Code generation | protoc-gen-grpc-web | Based on buf plugins |
Replacing packages
# Remove the previous (gRPC-Web) dependencies,
npm remove grpc-web google-protobuf
# and install the connect-web stack.
npm install @connectrpc/connect @connectrpc/connect-web @bufbuild/protobuf
Client code comparison
import { createConnectTransport } from "@connectrpc/connect-web";
import { createClient } from "@connectrpc/connect";
import { LanguageService } from "./gen/language_service_connect";
// Create the transport layer to the Bareun server.
const transport = createConnectTransport({
baseUrl: "https://api.bareun.ai",
});
const client = createClient(LanguageService, transport);
// Call AnalyzeSyntax
const res = await client.analyzeSyntax({
document: { content: "오늘 날씨가 좋네요.", language: "ko_KR" },
encodingType: "UTF16",
});
import { LanguageServiceClient } from "./gen/Language_serviceServiceClientPb";
import { AnalyzeSyntaxRequest, Document } from "./gen/language_service_pb";
const client = new LanguageServiceClient("https://...:5656");
const req = new AnalyzeSyntaxRequest();
const doc = new Document();
doc.setContent("오늘 날씨가 좋네요.");
doc.setLanguage("ko_KR");
req.setDocument(doc);
client.analyzeSyntax(req, {}, (err, res) => { /* ... */ });
Migration checklist
- Remove
grpc-webandgoogle-protobuf, and install the three connect-web packages - Switch proto code generation to the buf-based connect plugin
- Replace the client creation code with
createConnectTransport+createClient - Clean up endpoints: connect-web calls the Bareun server directly, without a separate Envoy proxy
- Check the request field names (
document,encodingType,customDictNames, etc.)
Fewer proxies
gRPC-Web usually had to go through a front proxy such as Envoy. The Bareun server (connect-go) accepts connect-web as is, so the setup becomes simpler.
Frequently asked questions
Q. If I switch to connect-web, do I have to change the server too?
No. The Bareun server is implemented with connect-go and accepts connect-web requests as is.
You call the same LanguageService, so you only replace the client, with no server change.
Q. Which packages does connect-web use?
It uses @connectrpc/connect, @connectrpc/connect-web, and
@bufbuild/protobuf for message serialization. Remove the existing grpc-web and google-protobuf.
Q. Does the structure of the analysis result change too?
The response message structure (sentence, eojeol (space-delimited word unit), morpheme, TextSpan position) is the same.
What changes is the transport and the client code; the analysis result itself is the same.