Versioned contracts at the edge
Your backend is probably Go, TypeScript, Python, Rust, or Rails, and it speaks JSON. Every response your frontend decodes has a shape, and sooner or later that shape changes.
For Lakeport apps, keep every response shape the backend may send in a single union in src/api/, and deploy the frontend first.
Why not /v1 and /v2 URLs?
Standard API advice is to version your URLs: keep /v1 additive, put breaking changes behind /v2, and run both until every client moves over. That works when a human checks every field change for compatibility.
We don't recommend that model for most Lakeport apps. Coding agents make breaking schema changes freely: ask for currency support and you may get a renamed field and a new nested object in the same diff. Small teams usually optimise for moving fast, and when an agent writes most of the code, nobody is checking that every /v1 change stayed additive and only /v2 breaks.
So express every forward version in your app instead, and release the app first. Match on the union without wildcard arms; Lean then rejects any match that misses a shape. It does not decide which screens need the union, or check that a decoder agrees with your API.
1. Model the shapes in src/api/
Suppose your backend is changing GET /api/orders/:id from a flat object (total_cents, status) to a nested object (amount.cents, amount.currency, refundable).
Keep the existing decoder and ask your agent to add the new shape beside it in one inductive type, decoded with LakeportJson:
2. Handle every case
In your reducers and .lp views, match on OrderSchema without a wildcard _ => arm. When you add a third shape later, every function that missed it fails compilation, and lakeport mcp gives your agent the exact file and line list.
This formatting sketch omits fractional cents; use a reviewed currency formatter in an app.
Here is how decodeOrderSchema and formatOrderSummary classify three responses from GET /api/orders/ord-42:
3. Release the frontend first
Do backends need to advertise their version?
For reads, no. If a response decodes as OrderSchema.v2, your frontend already has the parsed v2 record.
For new writes, advertising capability helps. Before showing a new Request instant refund button (POST /api/orders/:id/refund), the frontend needs to know the backend accepts that route. A response header such as X-Capabilities: instant-refund, or a boolean field in the JSON body, is enough. Read it from EffectResp.httpResponse, store it in your model, and check it in your reducer as well as hiding the button. shows that reducer check.
Services you own
The same rule extends across multiple services you own if their dependency graph is a DAG. Order the graph from left to right, with your frontend on the far left and services that depend on no other owned service on the far right. Release from left to right so each consumer ships support for the new shape before any service it calls starts sending it.
If the dependency graph has a cycle, no such release order exists. Break the cycle first.
Where this stops working
In a larger company, independent teams may own services you depend on and deploy on their own schedules. That boundary behaves like an external product, similar to calling Stripe's API. The app must follow that product’s compatibility and versioning contract.
In our view that isn't the situation for most Lakeport users and most apps, which is why frontend-first unions are the default we recommend. Use them for response shapes whose rollout you control, and follow the published contract of anything you don't.
A versioned union lets the new frontend you deploy decode every response shape your backend may send during its rollout and after a rollback. It does nothing for frontends already shipped before your release, which only know the shapes compiled into them. Whether your backend keeps serving older shapes for those clients is a backend decision; Lakeport makes no recommendation there.
Continue to for rolling deploys, write gating in reducers, stored client data, and asset caching.