Docs · Learn
Copy as Markdown
Recipes
Three common tasks in UJN, each with the text to copy, its drawing and the spec sections behind it.
UJN 0.1 draft · revision 23 · November 29, 2026 · Changes
Show the user leaving and coming back#
A handoff is where the user leaves the app or its channel: an email link, a bank app, a phone call (section 15). The arrow into it is where they leave. The arrows out of it say how they come back, so you pick those arrows by how the user returns.
They come back by a link#
@startujnjourney RESET "Reset password" view forgot { title: "Forgot password"; route: /forgot }action send_link { type: message; title: "Send reset link"; channel: email }handoff email_link { title: "Reset link"; channel: email; timeout: 24 h; resume: /reset/:token }view reset { title: "New password"; route: /reset/:token }view link_expired { title: "Link expired"; route: /reset/expired } forgot --> send_link : [Send link] { payload: [email] }send_link --> email_linkemail_link ..> reset : [Open link] validemail_link ..> link_expired : [Open link] expired@endujnEach way back is a resume arrow, ..>, out of the handoff, with what the user does out there as
its trigger. The two share [Open link], so each gets a guard (13.5, 15.4). The handoff's resume
key records the deep link they come back through (15.3). When the user comes back to the very view
they left, write { returns } on the arrow in instead, and the drawing adds the dashed way back under
it (13.7).
They come back after a failure#
@startujnjourney PAY "Pay with the bank app" start from_cart { description: "From the cart" }view checkout { title: "Checkout"; route: /checkout }handoff bank { title: "Bank app"; channel: bank app; timeout: 5 min; resume: /checkout/return }start back_from_bank { type: handoff-return; route: /checkout/return }view paid { title: "Payment received"; route: /checkout/done }end gave_up { type: abandoned; description: "Left at the bank" } from_cart --> checkoutcheckout --> bank : [Pay with bank app]bank ..> back_from_bank : [Approve]bank .x.> checkout : [Decline]bank ..> gave_up : [Close the app]back_from_bank --> paid@endujn[Approve]is a resume into a start of the typehandoff-return, which carries the route the user lands on. The handoff'sresumeand the start'sroutemust match (17.4).[Decline]is a failed resume,.x.>: a return in every way, drawn going back right beside the arrow it answers, with a failure's cross (13.7).[Close the app]goes into anabandonedend, which ends the journey (17.4).
They never come back#
type: no-return says the journey ends out there, and the box reads "Handoff, no return" (15.2).
Write only the arrow in: a no-return handoff with { returns } or a resume arrow is a warning
(15.4). Use it for a phone call, or for a sign-in provider that sends the user on to another app.
Which arrow, and why#
| How the user comes back | Write | Why |
|---|---|---|
| To the view they left | { returns } on the arrow in |
The drawing adds the way back (13.7) |
| Somewhere else | ..> out of the handoff, with a trigger |
A resume goes on with the flow (13.7, 15.4) |
| Through a route of its own | ..> into a handoff-return start |
The start carries that route (17.4) |
| After a failure | .x.> out of the handoff |
A failed resume goes back and is not a path forward (13.7) |
| Not at all | type: no-return, or ..> into an abandoned end |
The journey ends out there (15.2, 17.4) |
A --> or -x-> out of a handoff is a warning: a handoff is left only by its resume arrows (15.4).
Show a form error and retry#
A form sends its fields to an action that checks them, and the action's guards decide what happens next (14.4).
@startujnjourney GIFT "Redeem a gift card" start from_account { description: "From the account page" }view redeem { title: "Redeem gift card"; description: "Card number and PIN"; route: /gift-cards/redeem }action check_card { title: "Check card"; description: "Number, PIN and balance" }view wrong_pin { type: toast; title: "Card number or PIN is wrong" }view added { title: "Balance added"; route: /account/balance }view locked { title: "Too many tries"; description: "Try again in 1 hour"; route: /gift-cards/locked }end done { type: success; description: "Balance added" }end blocked { type: failure; description: "Locked out" } from_account --> redeemredeem -x-> redeem : [Redeem] a field is emptyredeem --> check_card : [Redeem] all fields filled { payload: [card_number, pin] }check_card --> added : validcheck_card -x-> wrong_pin : invalid, tries leftcheck_card -x-> locked : invalid, fifth trywrong_pin .x.> redeemadded --> done : [Done]locked --> blocked : [Close]@endujn- The form. Both exits are
[Redeem], so each needs a guard (13.5). An empty field never leaves the form: the negative arrow loops back to the same view, and the error shows there (13.1). - The check. The exits out of the action take no trigger, because the system acts, not the user (13.5). Among
guarded exits exactly one fires, so
valid,invalid, tries leftandinvalid, fifth trymust not overlap. Guarded and unguarded exits on one action are a warning (14.4). - The error.
-x->into the toast marks the failure. A toast goes away by itself, so its way back needs no label..x.>shows the loop is a failure's; a plain..>is right too (13.7). - The retry. Back on the form, the user presses Redeem again, and the same
[Redeem]arrow carries the next try. You draw no retry arrow: the return closes the loop and is drawn as the way back (13.7). - The lockout. A third guard sends the user to the lock screen by a negative arrow, and the journey ends as a failure. The guard is text: it states the rule, and UJN does not count the tries.
Variations:
- The error in the form, no toast. Send the failure straight back with a failed return:
check_card .x.> redeem : invalid, tries left(13.7). - A Try again button on an error screen. Write its way back as a return with a trigger,
card_error .x.> redeem : [Try again]. If you write it as navigation instead, give it a hint against the flow,-left->, since the token alone does not say it goes back (13.3). - A lock that lifts after a time. Add a
waitaction with atimeoutand an exit guardedtimeout(14.3).
Mark steps as planned, idea or legacy#
Flags say where a part of the journey stands. Put them in the flags list of a node's block or an
arrow's block (section 8, 13.8). Use future for a step planned for a later release, idea for a
concept not yet approved, and legacy for one that is old but staying; deprecated is the opposite
of legacy, behavior being retired. Review flags such as risk or needs-decision work the same
way but stay where they are set.
@startujnjourney CHECKOUT "Checkout" view checkout { title: "Checkout"; route: /checkout }action authorize { title: "Authorize payment" }action save_card { title: "Save card"; flags: [future] }view wallet { title: "Wallet"; route: /checkout/wallet }view pay_later { title: "Pay later"; description: "Invoice in 30 days"; route: /checkout/later; flags: [future] }action credit_check { title: "Credit check" }view transfer { title: "Bank transfer"; route: /checkout/transfer; flags: [legacy] }view confirmed { title: "Order confirmed"; route: /orders/:id } checkout --> authorize : [Pay by card]authorize --> save_cardauthorize --> confirmedcheckout --> wallet : [Pay with wallet] { flags: [idea] }wallet --> confirmed : [Pay]checkout --> pay_later : [Pay later]pay_later --> credit_check : [Continue]credit_check --> confirmedcheckout --> transfer : [Bank transfer]transfer --> confirmed : [I have paid]@endujnHow they carry down#
future,idea,deprecated,not-implementedandout-of-scopeare delivery flags. Each passes to everything reachable only through the flagged node or arrow (section 8, 13.8): Credit check inheritsfuturefrom Pay later, and Wallet inheritsideafrom the arrow into it.- Order confirmed inherits nothing, because the card path reaches it without a flag.
legacystays on Bank transfer, so the arrow after it stays solid. That is the current proposal; whetherlegacycarries down is still open (23.3).- Write only the flags you set. Writing an inherited flag sets it on that node (section 8). On an
arrow, flags go in its block: a
#futureafter the label would read as a color (13.8).
How they are drawn#
| You see | It means |
|---|---|
| A dotted border; the node keeps its shape | A flag, set or inherited (section 8) |
| A filled glyph tab inside the right edge | The flag is set on this node |
| An outlined glyph tab | The flag is inherited |
| A dotted arrow with a glyph tab right of its pill | The flag is set on this arrow (13.8) |
| A dotted arrow with no tab | It comes after a flagged node or arrow; the nodes carry the flag |
A flagged handoff keeps its dashed border (section 15), a flagged return keeps its open head, and a flagged negative keeps its cross (13.8). In color most flags have a color of their own (19.3), but color carries no meaning (section 10). In black and white the glyph tells the flags apart, and a filled or outlined tab tells set from inherited (19.4):
@startujnrender { colors: mono; legend }journey LATER "Pay later" view checkout { title: "Checkout"; route: /checkout }view pay_later { title: "Pay later"; route: /checkout/later; flags: [future] }action credit_check { title: "Credit check" }view transfer { title: "Bank transfer"; route: /checkout/transfer; flags: [legacy] } checkout --> pay_later : [Pay later]pay_later --> credit_check : [Continue]checkout --> transfer : [Bank transfer]@endujnlegacyandneeds-updateshave no glyph yet. Until they are designed, the module draws the letters L and U (23.4, 23.28).legendadds a strip under the drawing that explains what it uses: each kind of node and arrow, and each flag with its glyph and meaning (19.5).- In the model, each node and arrow lists the flags set on it under
flagsand the delivery flags that reach it underinherited(20.4, 20.5).