Differences from Spring
Spring has no navigation for apps, so this starter is new. It borrows Spring's names and rules where there is something to borrow. This page lists what carries over from Spring, and where it behaves differently.
Why
If you know Spring MVC or WebFlux, most of the router reads familiar: a path pattern on a class, a builder of routes, filters, scopes. Knowing where the likeness stops saves surprises.
Example
The same route in both:
// Spring WebFlux
RouterFunctions.route()
.GET("/books/{isbn}", handler::book)
.filter(adminOnly)
.build();
// Here
ScreenRoutes.route()
.screen('/books/{isbn}', (r) => const BookPage())
.filter(AdminOnly())
.build();
What carries over
| Spring | Here |
|---|---|
@GetMapping("/books/{isbn}") path patterns: {name}, {name:regex}, {*rest} |
The same syntax in @ScreenRoute |
RouterFunctions.route()...build() |
ScreenRoutes.route()...build() |
HandlerFilterFunction |
RouteFilter |
request and session scopes |
route and branch scopes |
@PreAuthorize on a method |
@PreAuthorize on a screen (with the security starter) |
RestTemplate, JdbcTemplate |
RouteTemplate, the API of the navigation |
springdoc's @Operation |
@RouteInfo |
What differs
- A route opens a widget, not a handler. There is no response: the screen reads its values from
context.route. - Query parameters are declared with their types (
params: {'page': int}) and converted before the screen opens; a value that does not convert shows the error screen, as a400would. - The extra object has no counterpart in HTTP: it is passed in memory and lost on a reload or a deep link.
- Shells keep a stack per branch, which no server has.
- Another address of the same route keeps the screen, its state and its scroll.
- A guard is not security. It hides screens on the device; the server must still check every request.
- Deep links are written into platform files at build time.
Limits
- Windows and Linux get no deep links yet.
- Screens with path variables get no pages for search engines unless
@RouteInfo(paths: [...])lists their addresses. SpringApplicationWidgettakes no bean overrides in tests.- The router knows no design library: without a design starter,
platformhas no transition andzoomandcupertinocannot be used (see Transitions).