Vaadin Hilla With React and Typed Endpoints from Java
Use Vaadin Hilla to build a React front end over Java endpoints with generated TypeScript clients, file based routing, authentication and when to choose Flow.

Hilla targets teams that want React for the interface and Java for the logic, without hand-writing the REST layer between them. This is for Vaadin 25 and Spring Boot 4.
What it adds
In a Flow application the UI is built in Java and rendered by the browser from server state. In a Hilla application the UI is a React single-page app, and the back end exposes methods. The glue is code generation: Hilla reads your Java classes and writes TypeScript clients with the matching types.
A back end service
@BrowserCallable
@AnonymousAllowed
public class TaskService {
public record Task(Long id, @NotBlank String title, boolean done) { }
private final TaskRepository repository;
public TaskService(TaskRepository repository) { this.repository = repository; }
public List<Task> list() { return repository.findAll().stream().map(Task::of).toList(); }
public Task save(Task task) { return Task.of(repository.save(task.toEntity())); }
}@BrowserCallable exposes the public methods. Hilla generates frontend/generated/endpoints.ts with a TaskService module and a Task type. Bean Validation constraints such as @NotBlank are exposed to the client form binder as well.
A React view
import { useEffect, useState } from 'react';
import { TaskService } from 'Frontend/generated/endpoints';
import type Task from 'Frontend/generated/dev/javahacks/TaskService/Task';
import { Button, TextField } from '@vaadin/react-components';
export default function TasksView() {
const [tasks, setTasks] = useState<Task[]>([]);
const [title, setTitle] = useState('');
useEffect(() => { TaskService.list().then(setTasks); }, []);
async function add() {
const saved = await TaskService.save({ title, done: false });
setTasks([...tasks, saved]);
setTitle('');
}
return (
<div className="p-m">
<TextField label="New task" value={title} onValueChanged={e => setTitle(e.detail.value)} />
<Button theme="primary" onClick={add}>Add</Button>
<ul>{tasks.map(t => <li key={t.id}>{t.title}</li>)}</ul>
</div>
);
}Calling TaskService.list() is a typed fetch to a generated endpoint. A change to the Java record updates the TypeScript type on the next build, and a mismatch becomes a compile error in the front end. Place the file in src/main/frontend/views/ and the router picks it up.
Routing
Hilla uses file-based routing: views/tasks.tsx becomes /tasks, views/@index.tsx the root, and views/@layout.tsx wraps its siblings. Route metadata, such as the title and the allowed roles, is exported from the file.
Security
The same Spring Security setup as Flow applies, extended with CSRF handling that the generated client takes care of. Protect an endpoint class or method:
@BrowserCallable
@RolesAllowed("ADMIN")
public class AuditService { ... }An endpoint without an annotation is denied by default. See Spring Security with Vaadin for the configuration.
Choosing between Flow and Hilla
| If you want | Pick |
|---|---|
| All code in Java, one language | Flow |
| A React team, rich client side logic | Hilla |
| A server-side view model, fewer API contracts | Flow |
| Reuse of a React component ecosystem | Hilla |
Both can live in one application, with Flow views and Hilla views side by side. Start with the comparison in the Vaadin guide.
How the typed endpoint works
Hilla generates TypeScript from your Java. A class annotated with @BrowserCallable becomes a set of typed functions in the front end: the method names, parameters and return types are read from the Java source and written to a generated folder, and the React code calls them as plain async functions. When you rename a method or change a field type in Java, the TypeScript compiler fails on the next build, which is the benefit of the whole approach: a contract between back end and front end that is checked by a compiler and not by a manual test.
The generation runs as part of the build and in development mode when the Java changes, so keep the generated folder out of version control, or commit it consistently as your team decides. Mixing the two policies produces diffs nobody wants to review.
State, forms and validation
Form handling is where the typed approach saves the most time. Java Bean Validation annotations on a record, such as @NotBlank and @Size, are carried to the front end through the generated model, so the form can validate before submitting and the server validates again, with the same rules written once. The server check stays mandatory: never rely on the browser for validation, since any client can call the endpoint directly. A validation failure from the server arrives as a typed error that the form can map to a field, which beats parsing messages out of a string.
For application state, use what React offers and keep the server as the source of truth. Fetch on navigation, keep the result in a local hook, and refetch after a mutation. Adding a global state library for the first screens is usually premature, and a few custom hooks cover most needs.
Testing both sides
Test the Java endpoint class as an ordinary Spring bean, with a unit or slice test and no browser. Test the React components with Vitest and the Testing Library, mocking the generated endpoint functions, so a front end test does not need a running server. Reserve a small end-to-end suite for the paths that cross both, such as login and one complete form submission, and run it against a built application, because generated code and bundling issues appear only there.
The honest trade-off
Hilla suits a team that knows Java well and wants a React front end with a type-safe link to its back end, without maintaining an OpenAPI file and a generated client by hand. It is a smaller ecosystem than a plain React and REST setup, and a front end specialist may prefer the usual tooling, including their own choice of router and data layer. If your front end is built by a separate team that wants complete freedom, a REST API with an OpenAPI contract is the cleaner boundary. If one team owns both halves and Java is the common language, Hilla removes a layer of glue.
Upgrading and keeping the front end healthy
Hilla projects have two dependency trees, Maven and npm, and each needs regular care. Update the Hilla version in the POM and let the plugin refresh the npm packages it manages, then run npm audit and keep third-party packages current like any other front end project. Keep the Node version pinned in the build, so a new developer or a CI agent builds the same bundle. When a build fails after an update, delete the generated front end folder and node_modules, rebuild once, and read the first error, which is nearly always a version mismatch and not a bug in your view.
Observing the endpoints
Hilla endpoints are ordinary Spring beans behind generated routes, so the usual tools work: add Micrometer timers to the endpoint methods, log failures with a correlation id and expose the same health checks as the rest of the application. Watching the call rate and error rate per endpoint shows which screens cost the most, and it tells you where to spend effort first.
Where this does not apply
Hilla assumes a Node toolchain at build time, which Vaadin downloads for you, and a front end build step the Flow-only team may not want. Production builds produce a bundle, see the production build. The reference is the Hilla documentation, and React covers the front end.


