<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Nergy101 Blog</title>
  <link href="https://blog.nergy.space/"/>
  <link href="https://blog.nergy.space/feed.xml" rel="self" type="application/atom+xml"/>
  <id>https://blog.nergy.space/</id>
  <updated>2026-11-27T10:59:35.644Z</updated>
  <subtitle>Technology, development, and software engineering from Christian / Nergy101.</subtitle>
  <dc:language>en-us</dc:language>
  <entry>
    <title>Technische schuld kost geld</title>
    <link href="https://blog.nergy.space/blogs/technische-schuld-kost-geld"/>
    <id>https://blog.nergy.space/blogs/technische-schuld-kost-geld</id>
    <published>2026-10-19T00:00:00.000Z</published>
    <updated>2026-10-19T00:00:00.000Z</updated>
    <author><name>Christian / Nergy101</name></author>
    <summary>Wanneer heb jij voor het laatst een nieuwe functionaliteit opgeleverd gekregen, zonder dat er eerst drie andere dingen moesten worden gerepareerd of preventief gewijzigd? Als je even moet nadenken, is dat antwoord al veelzeggend. Technische schuld is stil, sluipend en duur. En het ergste eraan? Dat…</summary>
    <content type="html">&lt;div class=&quot;container&quot;&gt;
                &lt;h1 id=&quot;technische-schuld-kost-geld-hoe-je-het-herkent-bij-je-software-team&quot;&gt;&lt;a href=&quot;#technische-schuld-kost-geld-hoe-je-het-herkent-bij-je-software-team&quot; class=&quot;header-anchor&quot;&gt;Technische schuld kost geld: hoe je het herkent bij je software team&lt;/a&gt;&lt;/h1&gt;&lt;p&gt;Wanneer heb jij voor het laatst een nieuwe functionaliteit opgeleverd gekregen, zonder dat er eerst drie andere dingen moesten worden gerepareerd of preventief gewijzigd? Als je even moet nadenken, is dat antwoord al veelzeggend. Technische schuld is stil, sluipend en duur. En het ergste eraan? Dat je er zo aan went dat je het niet meer ziet of door hebt. In dit artikel leer je waar je op moet letten, zelfs als je zelf geen ontwikkelaar bent.&lt;br&gt;&lt;h2 id=&quot;wanneer-stilstand-de-nieuwe-standaard-wordt&quot;&gt;&lt;a href=&quot;#wanneer-stilstand-de-nieuwe-standaard-wordt&quot; class=&quot;header-anchor&quot;&gt;Wanneer stilstand de nieuwe standaard wordt&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Veel softwareproducten hebben een geschiedenis. Ze zijn ooit gebouwd door een toegewijd team, gegroeid met de organisatie, en uitgebreid naarmate de business dat vroeg. Op papier draaien ze prima. Maar onder de oppervlakte vertelt de code vaak een ander verhaal.&lt;/p&gt;&lt;p&gt;Dit is de wereld waar een consultant regelmatig instapt.&lt;/p&gt;&lt;p&gt;De organisaties die we tegenkomen hebben doorgaans een langlopend softwareproduct, regelmatig meer dan tien jaar oud, dat wordt beheerd door een intern of extern ontwikkelteam. Dat team heeft het product door de jaren heen laten groeien, kent het door en door, en is er volledig op ingesteld. &lt;strong&gt;Op het eerste gezicht lijkt dat een kracht&lt;/strong&gt;. En dat was het ook, ooit...&lt;/p&gt;&lt;p&gt;Maar de technische wereld staat niet stil. Frameworks evolueren. Deployment-praktijken veranderen. Wat in 2016 een moderne aanpak was, is in 2026 achterhaald. De teams die we aantreffen hebben die ontwikkeling grotendeels gemist. Niet uit onwil, maar omdat ze zich comfortabel hebben gevestigd in wat ze kennen. Ze hebben in die zin hun technische piek bereikt, en zijn daar gebleven.&lt;/p&gt;&lt;p&gt;Het gevolg is vaak een omgeving die functioneert, maar nauwelijks meer beweegt. &lt;br&gt;En als je ernaar vraagt, is het antwoord dat iedereen inmiddels heeft geaccepteerd: &lt;em&gt;&quot;Dit is gewoon hoe het werkt. Dit is de realiteit van dit systeem.&quot;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Dat zinnetje is de aanleiding voor alles wat volgt.&lt;/p&gt;&lt;p&gt;Want wat als die realiteit helemaal niet zo vast staat als iedereen denkt? Wat als de vertraging geen eigenschap is van het product, maar een symptoom van iets wat te veranderen valt? &lt;/p&gt;&lt;p&gt;Precies die vraag brengt een consultant in beeld.&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;probleem-dit-is-gewoon-hoe-het-werkt&quot;&gt;&lt;a href=&quot;#probleem-dit-is-gewoon-hoe-het-werkt&quot; class=&quot;header-anchor&quot;&gt;Probleem: &quot;Dit is gewoon hoe het werkt&quot;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Elke change duurt minstens een week voor het online staat. Releases zijn spannende momenten in plaats van routineklussen. Nieuwe functionaliteiten worden steeds vaker uitgesteld ten gunste van fixes op wat al bestaat.&lt;/p&gt;&lt;p&gt;En als je ernaar vraagt, is het antwoord steevast hetzelfde: &lt;em&gt;&quot;Dit is gewoon hoe het werkt. Dit is de realiteit van dit systeem.&quot;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Dat zinnetje is het gevaarlijkste in de hele situatie. Want het normaliseert iets wat niet normaal is. Het maakt van een structureel probleem een geaccepteerde omgeving. En ondertussen wordt de stroop alleen maar dikker.&lt;/p&gt;&lt;p&gt;Wat je aantreft als je de motorkap echt optilt:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Geen of minimale testdekking.&lt;/strong&gt; Niemand weet zeker of een wijziging iets breekt, dus iedereen is voorzichtig en angstig voor veranderingen. Die voorzichtigheid kost veel tijd en momentum.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Geen geautomatiseerde CI/CD.&lt;/strong&gt; Releases zijn spannend, vaak handmatig, risicovol en nog het aller ergste: afhankelijk van specifieke mensen op specifieke momenten.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Amper documentatie.&lt;/strong&gt; Kennis zit in hoofden, niet in systemen. Onboarding, systeemplaten, worden snel gezien als &apos;overbodig&apos;. Iedereen heeft toch altijd precies dezelfde interpretatie van een bepaald domein en ieder proces?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Een Brent.&lt;/strong&gt; Iedereen die &lt;em&gt;The Phoenix Project&lt;/em&gt; heeft gelezen kent hem: de ene developer die &lt;strong&gt;alles weet, alles kan, en zonder wie niets kan worden opgeleverd&lt;/strong&gt;. Hij is &lt;em&gt;geen&lt;/em&gt; held. Hij is een &apos;single point of failure&apos; dat het hele systeem gijzelt. De personifactie van dat luikje in de Death-Star.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;En dan is er nog de werkvoorraad. Als je die analyseert, zie je het patroon meteen: meer fixes dan nieuwe functionaliteiten. Het team repareert constant wat al bestaat, en komt niet meer toe aan het leveren van nieuwe waarde.&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;aanpak-meenemen-niet-confronteren&quot;&gt;&lt;a href=&quot;#aanpak-meenemen-niet-confronteren&quot; class=&quot;header-anchor&quot;&gt;Aanpak: meenemen, niet confronteren&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Wanneer je als consultant aankaart dat er iets structureel mis is, stuit je bijna altijd op weerstand. &lt;em&gt;&quot;Onze mensen zijn toch goed? Ze zijn betrokken, ze werken hard.&quot;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Dat klopt ook. Maar stilstand is achteruitgang in de tech-wereld. Hard werken en efficient werken zijn twee verschillende dingen, dat geld ook voor &quot;goed zijn&quot; en &quot;goed blijven&quot; als ontwikkelaar. &lt;/p&gt;&lt;p&gt;De aanpak die goed werkt is er een van &lt;strong&gt;mensen meenemen, en positief confronteren.&lt;/strong&gt; Je behandelt de domeinkennis van het bestaande team als het waardevolle bezit dat het is. Zij kennen het product, de klant, de edge cases. Jij brengt technische vernieuwing mee en een lik van buitenaf. Die ruil werkt alleen als er wederzijds respect is.&lt;/p&gt;&lt;p&gt;In de praktijk betekent dit:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Stap 1 — Rand-organisatie op orde.&lt;/strong&gt;Scrum-events, een werkbord dat iedereen gebruikt, duidelijke werkvoorraad bepaling. Hier geldt één ijzeren wet: ShiSho (Shit-in-Shit-out). Een vage werkvoorraad levert vage oplossingen. Goede werkvoorraad bepaling onthult ook meteen de technische achterstalligheden. Die komen als eerste bovendrijven. Dat is vaak ook een grote blokker. &quot;We moeten nog zoveel oplossen voor we weer &apos;echte&apos; waarde kunnen leveren!&quot; - en dat klopt.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Stap 2 — Technische hygiëne herstellen.&lt;/strong&gt;CI/CD opzetten, testdekking opbouwen, deployment-afspraken maken. Niet als doel op zich, maar als fundament voor alles wat daarna komt. Dit is ook het moment om het team mee te nemen in wat er tegenwoordig mogelijk is. Niet als kritiek op wat ze deden, maar als opening naar wat ze kunnen worden. Dit versnelt het algehele software- en waarde- leveren proces ook. Zo is de grote blokker van Stap 1 ook sneller opgelost.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Stap 3 — Architectuur heroverwegen waar nodig.&lt;/strong&gt;Dit blijft vaak relatief beperkt bij bestaande teams, maar het gesprek moet wel gevoerd worden. Wordt er iets nieuws gebouwd? Dan wil je daar altijd iets over te zeggen hebben als consultant, zodat het op moderne manieren gebeurt, niet op de manieren van tien jaar geleden. Pleister-oplossingen moeten niet meer geaccepteerd worden. Dat is hoe het team in eerste instantie achter is gaan lopen op hun doelen.&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;oplossing-van-fixes-naar-waarde&quot;&gt;&lt;a href=&quot;#oplossing-van-fixes-naar-waarde&quot; class=&quot;header-anchor&quot;&gt;Oplossing: van fixes naar waarde&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;De verschuiving die je wilt zien, gaat van een werkvoorraad vol achterstalligheden naar een werkvoorraad die gedreven wordt door domein en business; nieuwe waarde voor de gebruiker creeeren.&lt;/p&gt;&lt;p&gt;Die verschuiving kost tijd. Reken op &lt;strong&gt;enkele maanden&lt;/strong&gt; voor merkbare technische verbeteringen: betere CI/CD, testdekking, zekerheid over kwaliteit. Reken op &lt;strong&gt;een jaar&lt;/strong&gt; voordat het team structureel nieuwe functionaliteiten levert en gewend is aan het noodzakelijke refinen van werk-items. Het spijt me, als je dacht dat je jaren van achterstallig onderhoud kon oplossen in een paar maanden. Dat is helaas niet zo.&lt;/p&gt;&lt;p&gt;Wat je niet moet doen, is je blindstaren op tooling-scores. Denk aan SonarQube, Sigrid en testdekking in percentages. Deze vertellen een deel van het verhaal, maar niet het hele verhaal. Het gaat uiteindelijk om vragen als: is dit product toekomstbestendig? Is het modern? Kan het de groei aan van gebruikers/features?&lt;/p&gt;&lt;p&gt;Dat zijn technische, complexe en toch soms subjectieve vragen. Maar het zijn wel de juiste.&lt;/p&gt;&lt;p&gt;Immers kan je 100% test-coverage hebben, de perfecte SonarQube en Sigrid scores hebben en toch het verkeerde systeem hebben gebouwd. Oepsie!&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;lessons-learned-wat-elke-opdrachtgever-zou-moeten-weten&quot;&gt;&lt;a href=&quot;#lessons-learned-wat-elke-opdrachtgever-zou-moeten-weten&quot; class=&quot;header-anchor&quot;&gt;Lessons learned: wat elke opdrachtgever zou moeten weten&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Je hoeft geen technische achtergrond te hebben om technische schuld te herkennen. Dit zijn de signalen:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Je werkvoorraad gaat meer over fixes dan over nieuwe functionaliteiten.&lt;/strong&gt; Als het grootste deel van wat je team doet bestaat uit het repareren van dingen die al bestaan, betaal je veel rente op technische schuld.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Je hebt een &quot;Brent&quot;.&lt;/strong&gt; Één persoon zonder wie alles stilstaat is geen troef, het is een risico. En een teken dat kennis niet is geborgd in het team.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Je team wijst altijd naar bepaalde personen.&lt;/strong&gt; Niet omdat deze persoon de enige is die iets kan, maar omdat hij of zij drie jaar geleden dat ene systeem heeft gebouwd en sindsdien is die kennis nooit overgedragen. Iedereen weet wie je moet hebben, maar niemand weet wat diegene eigenlijk weet. Dat is geen samenwerking, dat is een tikkende tijdbom.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Je ontwikkelaars praten nooit over nieuwe versies of releases.&lt;/strong&gt; Technologie staat nooit stil, en een team dat bijblijft, volgt actief de releasekalenders van de platformen waarop ze bouwen. Dat geldt voor élke stack: van een Microsoft-georiënteerd team verwacht je elk jaar een .NET-upgrade te zien in de werkvoorraad. Ook een Java-team hoort de overstap naar een nieuwe LTS-versie te plannen. Een frontend-team hoort te weten welke versie van hun framework actueel is. Het specifieke platform maakt niet uit, het patroon wel. Als dat gesprek nooit plaatsvindt, is dat een signaal dat het team niet langer meekijkt naar wat er buiten hun eigen systeem gebeurt.&lt;/p&gt;&lt;p&gt;Het grootste risico is niet dat je team slecht is of niet &apos;wil&apos;. Het is dat niemand door heeft dat ze achterlopen.&lt;/p&gt;&lt;p&gt;Technische schuld bouwt zich niet op in één sprint. Het sluipt erin, over maanden en jaren. Elk kwartaal dat een framework-upgrade wordt uitgesteld, elke feature die zonder tests wordt opgeleverd, elke Brent die iets bouwt zonder het over te dragen of goed te documenteren, het zijn kleine stappen. Afzonderlijk nauwelijks merkbaar. Samen vormen ze een rem die zo geleidelijk wordt ingedrukt dat niemand het moment kan aanwijzen waarop het fout ging.&lt;/p&gt;&lt;p&gt;Dat is precies waarom het zo moeilijk te spotten is van binnenuit. Je went aan het tempo. Je accepteert de doorlooptijden. En op het moment dat je je afvraagt waarom alles zo lang duurt, is de rem al jaren langzaam ingedrukt. En er is niet een iemand die dat bewust heeft laten gebeuren.&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;conclusie-sta-je-bijna-stil-of-beweeg-je-vooruit&quot;&gt;&lt;a href=&quot;#conclusie-sta-je-bijna-stil-of-beweeg-je-vooruit&quot; class=&quot;header-anchor&quot;&gt;Conclusie: sta je bijna stil, of beweeg je vooruit?&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Wat deze trajecten keer op keer laten zien, is dat technische schuld zelden ontstaat door slechte intenties. Teams stagneren omdat ze comfortabel zijn geworden in wat werkt, en omdat niemand van buitenaf vraagt wat er eigenlijk nog meer mogelijk is. De rem wordt zo langzaam ingedrukt dat niemand het voelt. Iedereen went aan het tempo, accepteert de doorlooptijden, en op het moment dat je je afvraagt waarom alles zo traag gaat, is de schuld al jaren opgebouwd. De oplossing blijkt vaak niet het vervangen van mensen of systemen, maar het structureren van de werkwijze, het herstellen van technische hygiëne en het meenemen van het bestaande team in een nieuwe manier van werken.&lt;/p&gt;&lt;p&gt;Technische schuld is geen technisch probleem. Het is een bedrijfsprobleem dat zich opbouwt over jaren, in kleine stappen, zonder dat iemand een bewust besluit neemt om achter te blijven. &lt;/p&gt;&lt;p&gt;Herken je dit? Je werkvoorraad staat vol fixes, kleine changes duren weken, er is één persoon zonder wie alles stilstaat en nieuwe functionaliteiten komen er maar niet van? Dan is het tijd om de vraag te stellen: &lt;em&gt;&quot;Hebben wij begeleiding nodig met het wegwerken van onze technische schuld?&quot;&lt;/em&gt; Hoe langer die vraag onbesproken blijft, hoe dieper de schuld kan ingroeien. Een team dat stilstaat hoeft niet vervangen te worden. Het moet weer tractie krijgen door begeleiding, een duidelijke werkwijze, en de ruimte om te leren wat er tegenwoordig mogelijk is. Dat is geen overbodige luxe. Dat is onderhoud aan je belangrijkste digitale assets.&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;neem-contact-op&quot;&gt;&lt;a href=&quot;#neem-contact-op&quot; class=&quot;header-anchor&quot;&gt;Neem contact op&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Sta je voor dezelfde uitdaging? Deze consultant hoort graag hoe het bij jou speelt. Neem contact op en laten we het gesprek starten.
            &lt;/div&gt;</content>
  </entry>
  <entry>
    <title>OpenLang Generative UI - Fenrir</title>
    <link href="https://blog.nergy.space/blogs/openlang-generative-ui-fenrir"/>
    <id>https://blog.nergy.space/blogs/openlang-generative-ui-fenrir</id>
    <published>2026-08-13T00:00:00.000Z</published>
    <updated>2026-08-13T00:00:00.000Z</updated>
    <author><name>Christian / Nergy101</name></author>
    <summary>Every question our business asks is legit; too bad we never build the dashboards they want...</summary>
    <content type="html">&lt;div class=&quot;container&quot;&gt;
                &lt;h1 id=&quot;openlang-generative-ui-fenrir&quot;&gt;&lt;a href=&quot;#openlang-generative-ui-fenrir&quot; class=&quot;header-anchor&quot;&gt;OpenLang Generative UI - Fenrir&lt;/a&gt;&lt;/h1&gt;&lt;p&gt;Every question our business asks is legit; too bad we never build the dashboards they want...&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why don&apos;t you?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Because every one of them means a new screen, a new query, a sprint item, a release. So they get triaged, and most of them quietly never get answered. Or worse, we one-off it with a SQL query and give them the raw numbers. The thought is hard to avoid: &lt;em&gt;if only we could have this built by an AI&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;So I did it, on a real platform, with real data.&lt;br&gt;&lt;h2 id=&quot;let-s-draw-the-setting-of-this-blog&quot;&gt;&lt;a href=&quot;#let-s-draw-the-setting-of-this-blog&quot; class=&quot;header-anchor&quot;&gt;Let&apos;s draw the setting of this blog&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Wolf is the system Cito uses for the Dutch national secondary-education exams. Its users are the account administrators and examiners at a school, and the vocabulary of the domain is the vocabulary of the exam calendar: an exam is taken in an exam period, at a given education level; a school groups its candidates into exam groups; every group then walks through marking — first marking, second marking, consultation, approval, export — under deadlines set by law rather than by a product owner.&lt;/p&gt;&lt;p&gt;In the two existing frontends: &lt;strong&gt;every screen shows data of one school.&lt;/strong&gt; Almost every repository method that returns exam groups takes a school code, an account, or one exam. That is not an accident - it is what authorization, navigation and page design are all built on.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Fenrir&lt;/strong&gt; is a third frontend project in that same workspace, and it is a proof of concept in the strict sense: it has no build artifact, no pipeline, no deployment. You ask it a question in plain language and it builds a screen for you — KPI cards, charts, tables, filters — with real Wolf data in it.&lt;/p&gt;&lt;p&gt;It started as curiosity rather than as a roadmap item. Two things had appeared that I wanted to try against a real, large domain instead of the usual to-do-list demo: &lt;strong&gt;the Model Context Protocol, and generative UI&lt;/strong&gt;. This post is about what came out of putting them together, and in particular about one design decision that turned out to carry the whole thing.&lt;br&gt;&lt;h2 id=&quot;the-questions-the-product-cannot-ask&quot;&gt;&lt;a href=&quot;#the-questions-the-product-cannot-ask&quot; class=&quot;header-anchor&quot;&gt;The questions the product cannot ask&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Start from the boundary. Because every screen in Wolf is anchored to one school, there is a whole class of questions the product cannot ask — not &quot;has not got a screen for yet&quot;, but &lt;em&gt;cannot ask&lt;/em&gt;, since asking would mean crossing the boundary the entire application is organised around:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Where is the country stuck in the marking pipeline, and how many candidates sit at each stage?&lt;/li&gt;
&lt;li&gt;Which exam is going to miss its submission deadline, and with how many unapproved candidates behind it?&lt;/li&gt;
&lt;li&gt;Which second-marking pairings have no marker assigned yet?&lt;/li&gt;
&lt;li&gt;Which schools need a phone call today?&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Every one of those is answerable from the data. None of them is answerable from a single screen. And the honest alternative — build a national dashboard for each — collapses on the second problem: &lt;strong&gt;the long tail.&lt;/strong&gt; Most questions get asked once. &quot;How does the pre-university track compare to the lowest vocational track in the second exam period?&quot; is worth two minutes of someone&apos;s attention and never worth a sprint, so it does not get asked at all, and the answer never influences anything. There is also a third-order effect: because trying a screen is expensive, nobody really knows which screen should be built next.&lt;/p&gt;&lt;p&gt;That is exactly the shape of problem an LLM looks good at, right up to the point where you notice what the data is. This is exam administration under statutory deadlines. Candidates are mostly minors; examiners and account administrators are named staff. A model that answers in prose will, sooner or later, produce a number that is close to right, or a name that looks plausible, and there is no way for the reader to tell which sentence was retrieved and which was generated. A chat surface over this data is not merely imprecise — it is the wrong artifact.&lt;/p&gt;&lt;p&gt;Two constraints, then, and they pull in opposite directions:&lt;/p&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;The answer has to be a &lt;strong&gt;screen&lt;/strong&gt;: figures, a chart with the shape of the data, the rows behind it, filters that actually filter.&lt;/li&gt;
&lt;li&gt;Every figure on that screen has to come out of Wolf, verifiably, and nothing else may ever appear there.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Constraint 2 is the hard one, and it is what most &quot;AI dashboard&quot; demos quietly skip.&lt;br&gt;&lt;h2 id=&quot;the-model-writes-the-program-mcp-fetches-the-numbers&quot;&gt;&lt;a href=&quot;#the-model-writes-the-program-mcp-fetches-the-numbers&quot; class=&quot;header-anchor&quot;&gt;The model writes the program. MCP fetches the numbers.&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The decision that resolves both constraints is a split, and it is the one thing I would carry to any other generative-UI project: &lt;strong&gt;the model writes a program; the program fetches the data.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Fenrir&apos;s model output is not prose, and it is not JSON with numbers in it. It is a program in OpenUI-Lang — OpenLang, the &lt;code&gt;@openuidev/&lt;em&gt;&lt;/code&gt; packages — a short sequence of &lt;code&gt;name = Component(...)&lt;/code&gt; assignments that describes a screen &lt;/em&gt;and declares the data that screen needs*. Every &lt;code&gt;Query(&quot;tool_name&quot;, {...})&lt;/code&gt; inside it is an MCP tool call that the browser performs while the screen renders.&lt;/p&gt;&lt;p&gt;Read that again from the model&apos;s point of view: it decides &lt;strong&gt;which&lt;/strong&gt; figures belong on the screen, in what shape, with which labels and which filters. It never decides &lt;strong&gt;what&lt;/strong&gt; those figures are. The numbers arrive later, over a different channel, from (hopefully) deterministic code.&lt;/p&gt;&lt;p&gt;So there are two chains, and they are deliberately not connected:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;text&quot; id=&quot;code-1795777174460-ib8mv19yv&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;text&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;1. Writing the screen
   browser → POST /api/genui/chat → LlmService → provider (claude/copilot/azure/mock)
           ← OpenUI-Lang, streamed back token by token

2. Filling the screen with data
   island Query() → POST /api/genui/tools/{name} → McpBridge → /mcp → Tools/*.cs → Logic → SQL
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Chain 1 has no database access. Chain 2 has no model in it. The LLM is not in the data path at all — it never sees a row, so it cannot paraphrase one, round one, or average two of them into a third. That single property is what makes the whole idea deployable-in-principle on real exam data, and it changes what a failure even looks like. A wrong answer from Fenrir is one of exactly three things:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;a &lt;strong&gt;wrong layout&lt;/strong&gt; — a pie chart where a ranking was wanted. Visible in a second, and cheap.&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;wrong tool argument&lt;/strong&gt; — every filter in Wolf is a closed vocabulary, so an invented exam period comes back as an error message rather than as a plausible-looking table.&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;missing screen&lt;/strong&gt; — the model states, in a callout, that Wolf does not hold what you asked for.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;What it cannot be is a wrong number. There is no code path that would produce one.&lt;br&gt;&lt;h3 id=&quot;why-the-data-goes-over-mcp&quot;&gt;&lt;a href=&quot;#why-the-data-goes-over-mcp&quot; class=&quot;header-anchor&quot;&gt;Why the data goes over MCP&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Here is the part that looks like over-engineering until you say the goal out loud. The tools run &lt;em&gt;inside the Wolf API process&lt;/em&gt;. Fenrir could have called the logic layer directly, one C# method to another. Instead there is &lt;code&gt;McpBridge&lt;/code&gt;: the application&apos;s own MCP client, pointed at its own &lt;code&gt;/mcp&lt;/code&gt; endpoint, over loopback HTTP.&lt;/p&gt;&lt;p&gt;That is a choice, not a necessity, and the class comment says so. What the generative UI actually depends on is the tool &lt;strong&gt;catalogue&lt;/strong&gt; — names, descriptions, JSON schemas, generated from the C# attributes and handed to the model — and that catalogue would be identical over a plain JSON endpoint.&lt;/p&gt;&lt;p&gt;What the hop buys:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;One dispatch path, by tool name.&lt;/strong&gt; There is no second route from the browser to Wolf&apos;s data. Not a convenience endpoint, not a &quot;just this one query&quot; controller.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The same protocol an external client speaks.&lt;/strong&gt; One make target exposes &lt;code&gt;/mcp&lt;/code&gt; to Claude Desktop or the MCP inspector, against the same thirty-six tools. A broken tool is therefore broken for everyone at once, rather than only for Fenrir — which is a much better failure mode than it sounds, because it gets noticed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;And, honestly: MCP was half the point.&lt;/strong&gt; This is a proof of concept &lt;em&gt;of MCP&lt;/em&gt; as much as of generative UI. If the protocol only ever works when the client is somebody else&apos;s chat app, it has not been proven.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;The cost is one loopback HTTP request with no session bookkeeping (&lt;code&gt;Stateless = true&lt;/code&gt;) — and one genuinely non-obvious problem. &lt;code&gt;/mcp&lt;/code&gt; requires the same sign-in and the same linked admin account as every other surface, so a loopback request without an &lt;code&gt;Authorization&lt;/code&gt; header is a 401: the bridge would lock itself out of the very endpoint it exists to reach. Hence a &lt;code&gt;DelegatingHandler&lt;/code&gt; that copies the header of whichever inbound request it is currently serving. Putting the token on the transport instead would freeze the first caller&apos;s token into an &lt;code&gt;HttpClient&lt;/code&gt; that every caller shares — a bug that works perfectly in a demo with one user.&lt;br&gt;&lt;h3 id=&quot;mcp-was-optional&quot;&gt;&lt;a href=&quot;#mcp-was-optional&quot; class=&quot;header-anchor&quot;&gt;MCP was optional&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Having said all that: nothing in the idea requires MCP. The load-bearing part is the split — the model writes the program, deterministic code fetches the numbers — and that split does not care about the transport. The island already resolves every &lt;code&gt;Query()&lt;/code&gt; through a plain function map, one entry per tool name. That function can call an MCP tool, but it can just as well do a &lt;code&gt;fetch()&lt;/code&gt; against an ordinary JSON REST endpoint.&lt;/p&gt;&lt;p&gt;If you already have a REST API with typed, documented parameters, that is the quicker path to generative UI: describe those endpoints to the model (an OpenAPI document does much the same job as the MCP tool catalogue), let each &lt;code&gt;Query()&lt;/code&gt; call one of them, and skip the bridge, the loopback request and the header-forwarding handler entirely. What you give up is the second client — Claude Desktop or the MCP inspector speaking the same protocol against the same tools. For a proof of concept &lt;em&gt;of MCP&lt;/em&gt; that mattered to me; for a team that just wants a generated screen over an API it already has, it probably does not.&lt;br&gt;&lt;h3 id=&quot;why-openlang-and-not-the-obvious-alternatives&quot;&gt;&lt;a href=&quot;#why-openlang-and-not-the-obvious-alternatives&quot; class=&quot;header-anchor&quot;&gt;Why OpenLang, and not the obvious alternatives&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Letting the model emit HTML or JSX was never seriously on the table: no component library, no data binding, and a rendering surface that will happily execute whatever arrives. The point of a UI &lt;em&gt;language&lt;/em&gt; is that the output is parsed into a known set of components with declared data dependencies — the model is writing inside a grammar you control, not producing a document you have to trust.&lt;/p&gt;&lt;p&gt;I did try &lt;strong&gt;Google GenKit&lt;/strong&gt; first. It is a capable framework, but it took noticeably more effort to get the same features out of it: a working CRUD screen, for example, was still mine to design, build and wire. OpenUI-Lang arrives with the component library, the grammar and the renderer, so the work moves to where the domain actually is — which tools to expose, and what the model is allowed to do with them.&lt;br&gt;&lt;h3 id=&quot;why-a-react-island-inside-an-angular-app&quot;&gt;&lt;a href=&quot;#why-a-react-island-inside-an-angular-app&quot; class=&quot;header-anchor&quot;&gt;Why a React island inside an Angular app&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The shell — chat, layout, state, services, auth — is Angular: standalone components, signals, zoneless. The OpenLang renderer is React. Rather than reimplement its parser and runtime in Angular, the renderer is bundled as a standalone IIFE that exposes a small imperative API on &lt;code&gt;window.FenrirIsland&lt;/code&gt;, and Angular drives it: &lt;code&gt;render(element, { response, isStreaming, onToolCall })&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;It is ~2.3 MB, and it is loaded as a plain static file outside the Angular build, so it cannot touch the bundle budgets of the two apps that actually ship. Two frameworks in one page is a cost; pretending you can port a React runtime for free is a bigger one.&lt;br&gt;&lt;h2 id=&quot;thirty-six-tools-four-endpoints-and-a-2-3-mb-island&quot;&gt;&lt;a href=&quot;#thirty-six-tools-four-endpoints-and-a-2-3-mb-island&quot; class=&quot;header-anchor&quot;&gt;Thirty-six tools, four endpoints and a 2.3 MB island&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;What that adds up to, concretely.&lt;br&gt;&lt;h3 id=&quot;a-tool-is-a-c-method&quot;&gt;&lt;a href=&quot;#a-tool-is-a-c-method&quot; class=&quot;header-anchor&quot;&gt;A tool is a C# method&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Eleven classes, thirty-six tools. There is no separate schema file and no registry to keep in sync: a tool is a method with an attribute, and the description is written for the model to read. This one is the marking funnel:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;csharp&quot; id=&quot;code-1795777174461-n9w0nldx3&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;csharp&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;[McpServerTool(Name = &amp;quot;marking_funnel&amp;quot;, UseStructuredContent = true, ReadOnly = true)]
[Description(&amp;quot;&amp;quot;&amp;quot;
    The national marking pipeline as a funnel: how many exam groups and candidates sit in
    each markingStatus (first marking → second marking → consultation → approval →
    approved → exported) ... Render stages as a funnel or ordered bar chart on
    order, and leadTimes as a table.
    &amp;quot;&amp;quot;&amp;quot;)]
public async Task&amp;lt;MarkingFunnel&amp;gt; MarkingFunnel(
    [Description(&amp;quot;Restrict to one exam period (1, 2 or 3). Omit for all periods.&amp;quot;)]
    int? examPeriod = null,
    [Description(&amp;quot;Restrict to one education level. Matched loosely. Omit for all levels.&amp;quot;)]
    string? educationLevel = null)
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Note the rendering hint in the middle of the API documentation (&quot;render the stages as a funnel or an ordered bar chart&quot;). That is not sloppiness — on this surface the tool description &lt;em&gt;is&lt;/em&gt; prompt engineering, and the same text serves both readers. Note also what the parameters are: nullable, with &quot;omit for all&quot; spelled out, because the most common thing a generated filter does is ask for everything.&lt;/p&gt;&lt;p&gt;The tools return &lt;strong&gt;projections, not entities&lt;/strong&gt;. No addresses, no e-mail addresses, no usernames, no scores. The account tools count accounts rather than listing them. Schools are named; people are counted. That is a property of the tool layer, not a rule in the prompt, which matters: it holds even when the model misbehaves, and it holds for the external MCP client too.&lt;/p&gt;&lt;p&gt;Five of those tools are the national ones — the marking funnel, the deadline radar, second-marking status, subject participation, and a scorecard per school. All five read one national scan: a single query across every internal exam group, cached for sixty seconds, aggregated in memory afterwards. These are precisely the questions from the top of this post, and they exist only because a tool does not have to belong to a screen.&lt;br&gt;&lt;h3 id=&quot;four-endpoints-and-nothing-else&quot;&gt;&lt;a href=&quot;#four-endpoints-and-nothing-else&quot; class=&quot;header-anchor&quot;&gt;Four endpoints, and nothing else&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;text&quot; id=&quot;code-1795777174461-6afe44fgl&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;text&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;GET  /api/genui/health         provider + MCP status
GET  /api/genui/tools/spec     tool specs, straight from MCP tools/list
POST /api/genui/tools/{name}   execute one Wolf tool, via McpBridge
POST /api/genui/chat           stream OpenUI-Lang from the configured provider
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Both surfaces — &lt;code&gt;/api/genui/&lt;em&gt;&lt;/code&gt; and &lt;code&gt;/mcp&lt;/code&gt; — require a valid sign-in &lt;/em&gt;and* a linked administration account. The split matters for the UI: a 401 means &quot;sign in&quot;, a 403 means &quot;you have no account in this system&quot;, and those are different screens with different buttons.&lt;/p&gt;&lt;p&gt;The provider behind &lt;code&gt;/chat&lt;/code&gt; is configurable per question: the local &lt;strong&gt;Claude CLI&lt;/strong&gt; by default (it uses the CLI&apos;s own sign-in, and nothing leaves the machine — which is the only reason this is acceptable on real exam data), the local &lt;strong&gt;Copilot CLI&lt;/strong&gt;, &lt;strong&gt;Azure OpenAI&lt;/strong&gt; (the one option that does send data off the machine, and it is labelled as such in the UI), or &lt;strong&gt;mock&lt;/strong&gt; for fixtures and tests.&lt;br&gt;&lt;h3 id=&quot;what-arrives-and-what-gets-rendered&quot;&gt;&lt;a href=&quot;#what-arrives-and-what-gets-rendered&quot; class=&quot;header-anchor&quot;&gt;What arrives, and what gets rendered&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The response streams token by token, and it is &lt;em&gt;not&lt;/em&gt; trustworthy input. Models narrate — &quot;I&apos;ll build you a dashboard…&quot; — or explain mid-answer that OpenLang has no function definitions. Feed that to a markdown-capable renderer and the user watches developer chatter appear in their dashboard for a second.&lt;/p&gt;&lt;p&gt;So the stream passes through one small pure module first, which is also the entire reason it is a separate file with its own tests rather than living inside a 2.3 MB React bundle:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174461-1sdue3mgp&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;/** An OpenUI-Lang program is a sequence of `name = Component(...)` assignments. Prose
 *  never starts a line that way, which is what lets us tell a program from narration. */
export const LOOKS_LIKE_PROGRAM = /^[ \t]*\$?[A-Za-z_][\w$]*[ \t]*=/m;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;code&gt;extractProgram&lt;/code&gt; takes the last fenced block (tolerating one that is still streaming), tests it, and returns &lt;code&gt;null&lt;/code&gt; if it does not look like a program. Better to show nothing than to show the model thinking out loud.&lt;/p&gt;&lt;p&gt;What survives looks like this — a real program from the mock provider&apos;s fixtures, building a national progress view of exams enrolled against exams submitted:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;text&quot; id=&quot;code-1795777174461-5ctbsdb7x&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;text&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;summary = Query(&amp;quot;exam_summary&amp;quot;, {}, {rows: []})
header = CardHeader(&amp;quot;National progress&amp;quot;, &amp;quot;Enrolled versus submitted, per exam&amp;quot;)
bar = BarChart(summary.rows.examName, [Series(&amp;quot;Schools enrolled&amp;quot;, summary.rows.schoolsEnrolled), Series(&amp;quot;Schools submitted&amp;quot;, summary.rows.schoolsSubmitted)], &amp;quot;grouped&amp;quot;)
tbl = Table([Col(&amp;quot;Exam&amp;quot;, summary.rows.examName), Col(&amp;quot;Schools enrolled&amp;quot;, summary.rows.schoolsEnrolled, &amp;quot;number&amp;quot;)])
root = Stack([header, bar, tbl])
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Four lines of layout and one line of data dependency. The &lt;code&gt;{rows: []}&lt;/code&gt; at the end of the &lt;code&gt;Query&lt;/code&gt; is the fallback, rendered the instant the statement parses — which is why the prompt insists it stays empty, forever, in every generated program. An invented example row in that position is shown to the user as real exam administration.&lt;br&gt;&lt;h3 id=&quot;the-data-path-per-call&quot;&gt;&lt;a href=&quot;#the-data-path-per-call&quot; class=&quot;header-anchor&quot;&gt;The data path, per call&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The generated program&apos;s &lt;code&gt;Query()&lt;/code&gt; calls land on a plain function map, one entry per tool name, memoized per render root. Two details there earned their comments:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;It is a &lt;strong&gt;concrete map, not a &lt;code&gt;Proxy&lt;/code&gt;.&lt;/strong&gt; A Proxy would happily answer to &lt;code&gt;callTool&lt;/code&gt;, and the renderer would then decide it was talking to an MCP client and take a different path entirely.&lt;/li&gt;
&lt;li&gt;It is &lt;strong&gt;memoized&lt;/strong&gt;, because &lt;code&gt;render&lt;/code&gt; runs on every streaming delta, and a fresh map identity on each one invites the renderer to re-run queries that had already settled.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Every call is reported to the Angular shell twice — once as pending, once settled with a duration and an ok/error — which is what lets the shell hold the surface back instead of flashing an empty fallback table, and what puts a visible list of &quot;these tools ran, and this is what they took&quot; under every generated screen. On this kind of surface that list is not a debugging nicety; it is the provenance of what you are looking at.&lt;/p&gt;&lt;p&gt;Writes are deliberately awkward. Anything whose name ends in &quot;save&quot; or &quot;delete&quot; is a &lt;code&gt;Mutation()&lt;/code&gt;, never a &lt;code&gt;Query()&lt;/code&gt;, never wired to run on page load, always behind a button the user presses. It returns a success flag and a message, and the prompt requires showing that message and re-running the matching query afterwards.&lt;br&gt;&lt;h3 id=&quot;containment&quot;&gt;&lt;a href=&quot;#containment&quot; class=&quot;header-anchor&quot;&gt;Containment&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Because this runs against national exam data, &quot;off&quot; has to mean off. The feature flag does not merely hide the UI: a feature filter removes the controller from the MVC model, so with the flag off the route table is identical to a build without the proof of concept. The local sign-in shortcut has three independent locks — the feature flag, its own setting, and an &lt;code&gt;IHostEnvironment.IsDevelopment()&lt;/code&gt; check in code — and it bypasses &lt;em&gt;authentication&lt;/em&gt; only, never &lt;em&gt;authorization&lt;/em&gt;: an address that is not in the user table gets the same &quot;no access&quot; screen it would get in production. And if the flag is on, startup logs a warning; if &lt;code&gt;/mcp&lt;/code&gt; is open, a second, differently worded one. Seeing either line in the logs of anything other than a development machine &lt;em&gt;is&lt;/em&gt; the bug.&lt;br&gt;&lt;h2 id=&quot;a-system-prompt-is-a-defect-log&quot;&gt;&lt;a href=&quot;#a-system-prompt-is-a-defect-log&quot; class=&quot;header-anchor&quot;&gt;A system prompt is a defect log&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The system prompt in &lt;code&gt;island/index.tsx&lt;/code&gt; is about 38 kB, and it opens with a comment telling the next developer not to trim it for brevity. That is because it is not a prompt in the &quot;you are a helpful assistant&quot; sense. It is a defect log: roughly ten paragraphs, each of which is a bug someone actually watched happen. Here are the ones worth stealing.&lt;br&gt;&lt;h3 id=&quot;the-silent-default-in-your-component-library-will-betray-you&quot;&gt;&lt;a href=&quot;#the-silent-default-in-your-component-library-will-betray-you&quot; class=&quot;header-anchor&quot;&gt;The silent default in your component library will betray you&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The bug that cost the most was not in the model, the protocol or the backend. It was this: a generated screen opens showing every exam period, the user picks period 2, and there is no way back. There is no &quot;all periods&quot; row in the select. Their only escape is to ask the entire question again.&lt;/p&gt;&lt;p&gt;The obvious spelling of that row — an option whose value is the empty string — cannot work in this stack, twice over:&lt;/p&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;The OpenLang select wrapper builds its option list with &lt;code&gt;items.filter((item) =&gt; item?.props?.value)&lt;/code&gt;. An empty string is falsy, so the row is dropped before it is ever rendered. No warning, anywhere.&lt;/li&gt;
&lt;li&gt;Underneath sits &lt;code&gt;@radix-ui/react-select&lt;/code&gt;, which reserves the empty string for &quot;nothing selected&quot;: &lt;code&gt;shouldShowPlaceholder(value) =&gt; value === &quot;&quot; || value === undefined&lt;/code&gt;. Even if the row survived, its value is the one string that means &lt;em&gt;no selection&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;So the option needs a real sentinel value, and something has to turn that value back into &quot;no filter&quot; before the tool call. In the generated program that looks like this — &lt;code&gt;&quot;all&quot;&lt;/code&gt; is the sentinel, meaning &quot;no filter&quot;:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;text&quot; id=&quot;code-1795777174461-vi77ased0&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;text&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;$examPeriod = &amp;quot;all&amp;quot;
examPeriodFilter = Select($examPeriod, [SelectItem(&amp;quot;all&amp;quot;, &amp;quot;All exam periods&amp;quot;), SelectItem(&amp;quot;1&amp;quot;, &amp;quot;Exam period 1&amp;quot;), ...])
groups = Query(&amp;quot;marking_funnel&amp;quot;, {examPeriod: $examPeriod == &amp;quot;all&amp;quot; ? &amp;quot;&amp;quot; : $examPeriod}, {stages: []})
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Two lessons, and the second is the more general one. First: generative UI inherits every quiet default of your component library, and the model cannot see them — it writes the reasonable thing and gets a dead end. Second: &lt;strong&gt;hold the invariant in more than one place, and name the authority.&lt;/strong&gt; The prompt asks the model to map the sentinel back. A client-side helper strips the sentinel anyway, so the visible call list stays honest about what was actually sent — and it skips mutations, because the save-a-notice tool takes free text, and a notice whose body is the word &quot;all&quot; is odd but legal. And the MCP bridge drops empty arguments server-side, where it is the authority. Three nets, one of which is load-bearing, and the code says which.&lt;br&gt;&lt;h3 id=&quot;never-let-a-fallback-be-plausible&quot;&gt;&lt;a href=&quot;#never-let-a-fallback-be-plausible&quot; class=&quot;header-anchor&quot;&gt;Never let a fallback be plausible&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A &lt;code&gt;Query()&lt;/code&gt; renders its fallback the moment the statement parses — before any data has arrived. So a &quot;realistic&quot; example row in a fallback is not placeholder content; it is fabricated exam administration, displayed to a user with nothing to mark it as fake. Every fallback stays &lt;code&gt;{rows: []}&lt;/code&gt;. Slow and empty is a state people understand. Wrong and confident is not.&lt;br&gt;&lt;h3 id=&quot;rendering-booleans-is-a-domain-decision&quot;&gt;&lt;a href=&quot;#rendering-booleans-is-a-domain-decision&quot; class=&quot;header-anchor&quot;&gt;Rendering booleans is a domain decision&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Two defects with one cause. A table cell is rendered as &lt;code&gt;String(cell)&lt;/code&gt;, so a bare boolean shows up as &quot;true&quot; or &quot;false&quot;, and a null or missing field renders as an empty cell with no warning at all — the row then reads as though nobody ever entered a value. Meanwhile some tools already hand back finished words rather than booleans, and a ternary on such a field prints the positive branch for every single row, because a non-empty string is truthy. The same wrong answer, everywhere, consistently — the worst kind. And &quot;unknown&quot; is not &quot;no&quot;: the system never recorded an answer, which is a third state that has to survive all the way to the screen.&lt;br&gt;&lt;h3 id=&quot;chat-history-for-a-program-writing-model-is-not-chat-history&quot;&gt;&lt;a href=&quot;#chat-history-for-a-program-writing-model-is-not-chat-history&quot; class=&quot;header-anchor&quot;&gt;Chat history for a program-writing model is not chat history&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Sending every previous program back with the next question broke twice. The cheap failure: the request grows by kilobytes per turn on top of a 38 kB system prompt. The expensive one: the model reads its own earlier programs as worked examples and starts repeating them instead of answering the new question.&lt;/p&gt;&lt;p&gt;Now only the last &lt;em&gt;successful&lt;/em&gt; program survives verbatim — that is the only thing a follow-up like &quot;and now per period&quot; can refer to. Older turns collapse into a single line: which question they answered and which tools they read. Failed and aborted turns get a sentence too, and deliberately not their text, because the error callout that Fenrir writes on failure is itself a valid two-line OpenLang program — which is exactly what you must not hand back to a model that writes programs.&lt;br&gt;&lt;h3 id=&quot;tool-descriptions-are-the-prompt&quot;&gt;&lt;a href=&quot;#tool-descriptions-are-the-prompt&quot; class=&quot;header-anchor&quot;&gt;Tool descriptions are the prompt&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;There is no separate &quot;AI layer&quot; in this design. The &lt;code&gt;[Description]&lt;/code&gt; on a C# method is what the model reads, rendering hints included, and the enum values on the parameters are what keep an impossible question from becoming a plausible table. If you build tools for a model, the API surface and the prompt are one artifact, maintained together.&lt;br&gt;&lt;h3 id=&quot;design-containment-before-you-build-the-feature&quot;&gt;&lt;a href=&quot;#design-containment-before-you-build-the-feature&quot; class=&quot;header-anchor&quot;&gt;Design containment before you build the feature&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A proof of concept that reads production-shaped data needs its off switch designed first, not retrofitted. A flag that actually removes routes, extra locks behind it, and a startup log line that screams when it is on — that is what makes it responsible to point this at a real database at all.&lt;br&gt;&lt;h3 id=&quot;the-prompt-rules-are-the-one-thing-nothing-tests&quot;&gt;&lt;a href=&quot;#the-prompt-rules-are-the-one-thing-nothing-tests&quot; class=&quot;header-anchor&quot;&gt;The prompt rules are the one thing nothing tests&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Every other invariant in Fenrir is enforced by code: the tool layer returns projections, the bridge validates enums, the extractor rejects narration. The ten paragraphs of the system prompt are not. Each of them fixes a failure someone watched happen, and nothing checks whether editing one breaks a rule another paragraph was holding up. If you build this, assume your prompt is production code with no test suite — because that is what it is.&lt;br&gt;&lt;h2 id=&quot;where-this-actually-shines&quot;&gt;&lt;a href=&quot;#where-this-actually-shines&quot; class=&quot;header-anchor&quot;&gt;Where this actually shines&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The honest answer is that it is not &quot;everywhere&quot;, and it is also not quite where I expected. Three cases stand out.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;The long tail of one-off questions.&lt;/strong&gt; This is the real win. Most questions about a large dataset are asked once: this exam, this period, compared to that education level, today. A dashboard is an expensive answer to a question with a lifetime of two minutes, so those questions get triaged away and their answers never influence anything. A generated screen has almost no marginal cost, which changes which questions are worth asking at all.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Exploration — finding out what the screen should be.&lt;/strong&gt; A generated dashboard is the cheapest prototype in existence. Ask for it, look at it, notice that the KPI you assumed was central is boring and the funnel next to it is not. Then go and build &lt;em&gt;that&lt;/em&gt;, by hand, properly, as a real feature. Generative UI as a design tool turned out to be more immediately useful than generative UI as a product feature.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Onboarding into a complex domain.&lt;/strong&gt; Wolf has a vocabulary — exam periods, exam groups, marking statuses, school codes — and normally you learn it by being walked through screens. Someone who does not know the system can now ask their way into it in plain language, and get a picture back with the right words on it. Watching a newcomer do that is the demo that consistently lands.&lt;/p&gt;&lt;p&gt;What it is &lt;em&gt;not&lt;/em&gt; good at, on this data, and I would say the same about most enterprise domains: it is not a replacement for the screens people use every day. Those need to be stable, learnable, tested, accessible, and identical for every user on every visit — five properties a generated surface does not have. The two coexist: the product answers the questions you always have, and this answers the ones you did not know you had.&lt;br&gt;&lt;h2 id=&quot;programs-are-artifacts-not-chat&quot;&gt;&lt;a href=&quot;#programs-are-artifacts-not-chat&quot; class=&quot;header-anchor&quot;&gt;Programs are artifacts, not chat&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A generated program contains the layout and the &lt;em&gt;declarations&lt;/em&gt; of the data it needs, but never the data itself. It is a short piece of text, and that has consequences that are easy to miss while you are busy watching the demo:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Save it, and re-hydrate it later.&lt;/strong&gt; Store the program, open it next week, and its &lt;code&gt;Query()&lt;/code&gt; calls run again against whatever Wolf holds &lt;em&gt;then&lt;/em&gt;. Same screen, fresh numbers. Nothing can go stale, because no numbers were ever stored in the first place.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Share it, and keep it.&lt;/strong&gt; A saved program can be sent to a colleague. The tools run under the sign-in of whoever opens it, so they get the same screen filled with the data &lt;em&gt;they&lt;/em&gt; are allowed to see.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;It is as fast as your API.&lt;/strong&gt; The slow part of generative UI is the model coming up with the program: tokens streaming in, one after the other. Once you already have the program, rendering it costs no more than the tool calls it declares. A question that gets asked every Monday should be generated once and then kept.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;That last point is also how the two worlds from the previous section meet: a generated screen that turns out to be asked for again and again is a candidate to be saved, and then, eventually, to be built by hand.&lt;br&gt;&lt;h2 id=&quot;what-i-would-keep&quot;&gt;&lt;a href=&quot;#what-i-would-keep&quot; class=&quot;header-anchor&quot;&gt;What I would keep&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The interesting work turned out not to be the generation. Getting a model to emit a valid OpenLang program was an afternoon; everything after that was learning what a generated screen does to real users. A filter that cannot go back to &quot;all&quot; is a dead end. A fallback with a plausible row in it is fabricated exam administration. A word like &quot;no&quot; is a truthy string, and it gives the same wrong answer on every row. A model that sees its own earlier programs starts repeating them instead of answering the question.&lt;/p&gt;&lt;p&gt;The 38 kB system prompt is a defect log, one paragraph per bug someone actually watched happen.&lt;/p&gt;&lt;p&gt;Which leaves the one decision I would keep on any project of this kind: keep the model out of the data path. Let it write the program, let the protocol fetch the numbers. Every remaining mistake then becomes a layout mistake or a rejected argument — annoying, visible, cheap. That is a class of failure you can live with; &quot;probably about 4,200 candidates&quot; is not.&lt;/p&gt;&lt;p&gt;&lt;hr&gt;&lt;/p&gt;&lt;p&gt;Anyone who wants to spar about this is always welcome to send me a message — I am especially curious where you would draw the line between the program and the data. And if you would rather just find out for yourself: one MCP tool over a table you already have, one &lt;code&gt;Query()&lt;/code&gt; in a generated program, and you are holding this whole architecture in miniature.
            &lt;/div&gt;</content>
  </entry>
  <entry>
    <title>Angular Signal Forms</title>
    <link href="https://blog.nergy.space/blogs/angular-signal-forms"/>
    <id>https://blog.nergy.space/blogs/angular-signal-forms</id>
    <published>2026-01-28T00:00:00.000Z</published>
    <updated>2026-01-28T00:00:00.000Z</updated>
    <author><name>Christian / Nergy101</name></author>
    <summary>For years, Angular developers have been choosing between two approaches for handling forms: Template-driven forms (simple but limited) or Reactive Forms (powerful but verbose). While Reactive Forms became the go-to for complex applications, they always felt like they required a bit too much…</summary>
    <content type="html">&lt;div class=&quot;container&quot;&gt;
                &lt;h1 id=&quot;angular-signal-forms-a-new-era-for-forms-in-angular&quot;&gt;&lt;a href=&quot;#angular-signal-forms-a-new-era-for-forms-in-angular&quot; class=&quot;header-anchor&quot;&gt;Angular Signal Forms: A New Era for Forms in Angular&lt;/a&gt;&lt;/h1&gt;&lt;p&gt;For years, Angular developers have been choosing between two approaches for handling forms: Template-driven forms (simple but limited) or Reactive Forms (powerful but verbose). While Reactive Forms became the go-to for complex applications, they always felt like they required a bit too much boilerplate. But with Angular 21, there&apos;s a new kid on the block: &lt;strong&gt;Signal Forms&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;I&apos;ve been playing around with Signal Forms lately, building a small demo app to really understand how they work. And I have to say, I&apos;m impressed. This new API brings together the best of both worlds: the reactivity and power of Reactive Forms with the simplicity and elegance that Angular Signals provide.&lt;br&gt;&lt;h2 id=&quot;table-of-contents&quot;&gt;&lt;a href=&quot;#table-of-contents&quot; class=&quot;header-anchor&quot;&gt;Table of Contents&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#angular-signal-forms-a-new-era-for-forms-in-angular&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Angular Signal Forms: A New Era for Forms in Angular&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#table-of-contents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Table of Contents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#a-brief-history-of-angular-forms&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;A Brief History of Angular Forms&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#why-signals-change-everything&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Why Signals Change Everything&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#getting-started-with-signal-forms&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Getting Started with Signal Forms&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#core-concepts&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Core Concepts&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#signal-models-your-forms-data&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Signal Models: Your Form&apos;s Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#creating-forms-with-the-form-function&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Creating Forms with the form() Function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#the-field-directive&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;The Field Directive&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;a href=&quot;#template-integration&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Template Integration&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#accessibility-built-in&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Accessibility Built-In&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#error-display-with-modern-control-flow&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Error Display with Modern Control Flow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#displaying-all-form-errors&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Displaying All Form Errors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#real-time-form-state-visualization&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Real-Time Form State Visualization&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;a href=&quot;#advanced-features&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Advanced Features&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#custom-validation-logic&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Custom Validation Logic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#async-validation&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Async Validation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#form-state-tracking&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Form State Tracking&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#onpush-change-detection&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;OnPush Change Detection&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;a href=&quot;#data-flow-architecture&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Data Flow Architecture&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#comparison-with-traditional-forms&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Comparison with Traditional Forms&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#benefits-and-considerations&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Benefits and Considerations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#practical-implementation-tips&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Practical Implementation Tips&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#conclusion&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;a-brief-history-of-angular-forms&quot;&gt;&lt;a href=&quot;#a-brief-history-of-angular-forms&quot; class=&quot;header-anchor&quot;&gt;A Brief History of Angular Forms&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let&apos;s take a quick trip down memory lane. Angular has always had two ways to handle forms:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Template-driven forms&lt;/strong&gt; are the simpler approach. You use directives like &lt;code&gt;ngModel&lt;/code&gt; in your templates, and Angular handles most of the wiring behind the scenes. They&apos;re great for simple forms but quickly become unwieldy as complexity grows. Testing them is also a pain because so much logic lives in the template.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Reactive Forms&lt;/strong&gt; gave us more control. You define your form structure in TypeScript using &lt;code&gt;FormGroup&lt;/code&gt;, &lt;code&gt;FormControl&lt;/code&gt;, and &lt;code&gt;FormArray&lt;/code&gt;. This approach is powerful and testable, but it comes with a lot of boilerplate. Every time I create a reactive form, I find myself writing the same patterns over and over: creating controls, setting validators, subscribing to value changes, manually handling state...&lt;/p&gt;&lt;p&gt;Both approaches have served us well, but they were built before Signals revolutionized Angular&apos;s reactivity model.&lt;br&gt;&lt;h2 id=&quot;why-signals-change-everything&quot;&gt;&lt;a href=&quot;#why-signals-change-everything&quot; class=&quot;header-anchor&quot;&gt;Why Signals Change Everything&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Angular Signals, introduced in Angular 16 and becoming the recommended approach in more recent versions, fundamentally changed how we think about reactive state in Angular. Instead of relying on RxJS observables for everything or manually triggering change detection, signals provide a more intuitive and performant way to handle reactive data.&lt;/p&gt;&lt;p&gt;Here&apos;s what makes signals special:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Fine-grained reactivity&lt;/strong&gt;: Only the parts of your template that depend on a signal re-render when it changes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Simple syntax&lt;/strong&gt;: No need to pipe async values or manually subscribe/unsubscribe&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Better performance&lt;/strong&gt;: Works seamlessly with OnPush change detection&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Intuitive API&lt;/strong&gt;: Reading a signal with &lt;code&gt;()&lt;/code&gt; and updating with &lt;code&gt;.set()&lt;/code&gt; or &lt;code&gt;.update()&lt;/code&gt; just feels natural&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;So when the Angular team announced Signal Forms in Angular 21, it made perfect sense. Why not bring this elegant reactivity model to forms?&lt;br&gt;&lt;h2 id=&quot;getting-started-with-signal-forms&quot;&gt;&lt;a href=&quot;#getting-started-with-signal-forms&quot; class=&quot;header-anchor&quot;&gt;Getting Started with Signal Forms&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let me show you what you need to get started. First, make sure you&apos;re on Angular 21 or higher:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;json&quot; id=&quot;code-1795777174519-vcrmgihht&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;json&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &amp;quot;dependencies&amp;quot;: {
    &amp;quot;@angular/common&amp;quot;: &amp;quot;^21.0.0&amp;quot;,
    &amp;quot;@angular/core&amp;quot;: &amp;quot;^21.0.0&amp;quot;,
    &amp;quot;@angular/forms&amp;quot;: &amp;quot;^21.0.0&amp;quot;
  }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;The Signal Forms API lives in &lt;code&gt;@angular/forms/signals&lt;/code&gt;, which is separate from the traditional forms APIs. Here&apos;s what you&apos;ll import:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174519-dz75tw5eu&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { form, Field, required, validate, validateHttp, debounce } from &amp;#x27;@angular/forms/signals&amp;#x27;;
import { signal } from &amp;#x27;@angular/core&amp;#x27;;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;That&apos;s it! You&apos;re ready to build signal-based forms.&lt;br&gt;&lt;h2 id=&quot;core-concepts&quot;&gt;&lt;a href=&quot;#core-concepts&quot; class=&quot;header-anchor&quot;&gt;Core Concepts&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let me walk you through the core concepts using a practical example. I built a simple person form that demonstrates all the key features of Signal Forms.&lt;br&gt;&lt;h3 id=&quot;signal-models-your-form-s-data&quot;&gt;&lt;a href=&quot;#signal-models-your-form-s-data&quot; class=&quot;header-anchor&quot;&gt;Signal Models: Your Form&apos;s Data&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The first step is defining your form&apos;s data model. In Signal Forms, your model is just a regular signal:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174520-zfgwxoev8&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;interface Person {
  name: string;
  age: number;
}

// Step 1: Create a form model with signal()
personModel = signal&amp;lt;Person&amp;gt;({
  name: &amp;#x27;&amp;#x27;,
  age: 0,
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;This is beautifully simple. Your form data lives in a signal, which means it&apos;s reactive from the start. No need to create &lt;code&gt;FormControl&lt;/code&gt; instances or wire up value accessors manually.&lt;br&gt;&lt;h3 id=&quot;creating-forms-with-the-form-function&quot;&gt;&lt;a href=&quot;#creating-forms-with-the-form-function&quot; class=&quot;header-anchor&quot;&gt;Creating Forms with the form() Function&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Here&apos;s where Signal Forms really shine. You pass your model signal to the &lt;code&gt;form()&lt;/code&gt; function, and it gives you back a &lt;code&gt;FieldTree&lt;/code&gt; with all the reactive form state you need:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174520-6cyphhdl0&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// Step 2: Pass the form model to form() to create a FieldTree
personForm = form(this.personModel, (schemaPath) =&amp;gt; {
  // Add validation rules
  required(schemaPath.name, { message: &amp;#x27;Name is required&amp;#x27; });
  required(schemaPath.age, { message: &amp;#x27;Age is required&amp;#x27; });
  
  validate(schemaPath.age, ({ value }) =&amp;gt; {
    if (value() &amp;lt; 0) {
      return {
        kind: &amp;#x27;age-error&amp;#x27;,
        message: &amp;#x27;Age must be non-negative&amp;#x27;,
      };
    }

    if (value() &amp;lt; 18 || value() &amp;gt; 65) {
      return null; // Valid
    }

    return {
      kind: &amp;#x27;age-error&amp;#x27;,
      message: &amp;#x27;Age must be between lower than 18 or higher than 65&amp;#x27;,
    };
  });
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Let me break down what&apos;s happening here:&lt;/p&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;form()&lt;/code&gt; function takes your model signal and a configuration function&lt;/li&gt;
&lt;li&gt;The configuration function receives a &lt;code&gt;schemaPath&lt;/code&gt; that mirrors your model&apos;s structure&lt;/li&gt;
&lt;li&gt;You add validators using functions like &lt;code&gt;required()&lt;/code&gt; and &lt;code&gt;validate()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Custom validators receive a signal for the field&apos;s value and return either &lt;code&gt;null&lt;/code&gt; (valid) or an error object&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Notice how type-safe this is. The &lt;code&gt;schemaPath&lt;/code&gt; knows about &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;age&lt;/code&gt; because TypeScript infers it from your &lt;code&gt;Person&lt;/code&gt; interface. Try to validate a field that doesn&apos;t exist, and you&apos;ll get a compile error. This is exactly the kind of developer experience I love.&lt;br&gt;&lt;h3 id=&quot;the-field-directive&quot;&gt;&lt;a href=&quot;#the-field-directive&quot; class=&quot;header-anchor&quot;&gt;The Field Directive&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Binding your form to the template is incredibly simple with the &lt;code&gt;[field]&lt;/code&gt; directive:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;html&quot; id=&quot;code-1795777174520-x033sfizz&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;html&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;input
  id=&amp;quot;name-input&amp;quot;
  type=&amp;quot;text&amp;quot;
  [field]=&amp;quot;personForm.name&amp;quot;
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;That&apos;s it. One directive, and Angular handles all the two-way binding, validation, and state tracking for you. Compare this to reactive forms where you need &lt;code&gt;formControlName&lt;/code&gt; and have to set up a &lt;code&gt;FormGroup&lt;/code&gt; in the template. Signal Forms eliminate all that ceremony.&lt;br&gt;&lt;h2 id=&quot;template-integration&quot;&gt;&lt;a href=&quot;#template-integration&quot; class=&quot;header-anchor&quot;&gt;Template Integration&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let&apos;s look at how Signal Forms work in your templates. The integration is clean and modern, taking advantage of Angular&apos;s latest features.&lt;br&gt;&lt;h3 id=&quot;accessibility-built-in&quot;&gt;&lt;a href=&quot;#accessibility-built-in&quot; class=&quot;header-anchor&quot;&gt;Accessibility Built-In&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;One thing I really appreciate about the Signal Forms approach is how easy it makes proper accessibility. Here&apos;s how I added ARIA attributes to my form:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;html&quot; id=&quot;code-1795777174520-r223sokw1&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;html&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;input
  id=&amp;quot;name-input&amp;quot;
  type=&amp;quot;text&amp;quot;
  [field]=&amp;quot;personForm.name&amp;quot;
  [attr.aria-invalid]=&amp;quot;
    personForm.name().touched() ? (personForm.name().invalid() ? &amp;#x27;true&amp;#x27; : &amp;#x27;false&amp;#x27;) : null
  &amp;quot;
  [attr.aria-valid]=&amp;quot;
    personForm.name().touched() &amp;amp;&amp;amp; personForm.name().valid() ? &amp;#x27;true&amp;#x27; : null
  &amp;quot;
  [attr.aria-describedby]=&amp;quot;
    personForm.name().touched() &amp;amp;&amp;amp; personForm.name().invalid() ? &amp;#x27;name-errors&amp;#x27; : null
  &amp;quot;
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;The form field exposes signals for every piece of state you need:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;personForm.name().touched()&lt;/code&gt; - Has the user interacted with this field?&lt;/li&gt;
&lt;li&gt;&lt;code&gt;personForm.name().invalid()&lt;/code&gt; - Does the field have validation errors?&lt;/li&gt;
&lt;li&gt;&lt;code&gt;personForm.name().valid()&lt;/code&gt; - Is the field valid?&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;These signals make it trivial to set up proper ARIA attributes for screen readers. The reactivity is automatic—when the field state changes, the ARIA attributes update immediately.&lt;br&gt;&lt;h3 id=&quot;error-display-with-modern-control-flow&quot;&gt;&lt;a href=&quot;#error-display-with-modern-control-flow&quot; class=&quot;header-anchor&quot;&gt;Error Display with Modern Control Flow&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Angular&apos;s new control flow syntax (&lt;code&gt;@if&lt;/code&gt;, &lt;code&gt;@for&lt;/code&gt;) pairs perfectly with Signal Forms:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;html&quot; id=&quot;code-1795777174520-69yy94m4q&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;html&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;@if (personForm.name().touched() &amp;amp;&amp;amp; personForm.name().invalid()) {
  &amp;lt;ul id=&amp;quot;name-errors&amp;quot; class=&amp;quot;error-list&amp;quot; role=&amp;quot;alert&amp;quot; aria-live=&amp;quot;polite&amp;quot;&amp;gt;
    @for (error of personForm.name().errors(); track error) {
      &amp;lt;li&amp;gt;{{ error.message }}&amp;lt;/li&amp;gt;
    }
  &amp;lt;/ul&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;This reads almost like plain English:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;If&lt;/strong&gt; the name field is touched &lt;strong&gt;and&lt;/strong&gt; invalid&lt;/li&gt;
&lt;li&gt;Display an error list&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;For&lt;/strong&gt; each error in the errors array&lt;/li&gt;
&lt;li&gt;Show the error message&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;The &lt;code&gt;errors()&lt;/code&gt; signal returns an array of error objects, each with the message we defined in our validators. No more checking &lt;code&gt;hasError()&lt;/code&gt; for specific validator names or digging through error objects manually.&lt;br&gt;&lt;h3 id=&quot;displaying-all-form-errors&quot;&gt;&lt;a href=&quot;#displaying-all-form-errors&quot; class=&quot;header-anchor&quot;&gt;Displaying All Form Errors&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Sometimes you want to show all form errors in one place, like at the top of the form. Signal Forms makes this easy too! You can iterate through all fields and their errors:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;html&quot; id=&quot;code-1795777174520-bwctyod5n&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;html&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;form (submit)=&amp;quot;onSubmit($event)&amp;quot; class=&amp;quot;person-form&amp;quot;&amp;gt;
  @if (personForm().touched() &amp;amp;&amp;amp; personForm().invalid()) {
    &amp;lt;div class=&amp;quot;form-errors&amp;quot; role=&amp;quot;alert&amp;quot; aria-live=&amp;quot;polite&amp;quot;&amp;gt;
      &amp;lt;h3&amp;gt;Please fix the following errors:&amp;lt;/h3&amp;gt;
      &amp;lt;ul&amp;gt;
        @for (field of [personForm.name(), personForm.age()]; track field) {
          @if (field.touched() &amp;amp;&amp;amp; field.invalid()) {
            @for (error of field.errors(); track error) {
              &amp;lt;li&amp;gt;{{ error.message }}&amp;lt;/li&amp;gt;
            }
          }
        }
      &amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
  }
  
  &amp;lt;!-- Rest of form fields --&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Or, if you prefer a more dynamic approach that doesn&apos;t require manually listing fields, you can create a helper method in your component:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174520-exr77bi7w&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;getAllFormErrors() {
  const errors: string[] = [];
  
  // Iterate through all fields
  const fields = [
    { name: &amp;#x27;Name&amp;#x27;, field: this.personForm.name() },
    { name: &amp;#x27;Age&amp;#x27;, field: this.personForm.age() }
  ];
  
  for (const { name, field } of fields) {
    if (field.touched() &amp;amp;&amp;amp; field.invalid()) {
      for (const error of field.errors()) {
        errors.push(`${name}: ${error.message}`);
      }
    }
  }
  
  return errors;
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Then in your template:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;html&quot; id=&quot;code-1795777174520-xyadharxz&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;html&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;@if (personForm().invalid() &amp;amp;&amp;amp; personForm().touched()) {
  &amp;lt;div class=&amp;quot;form-summary-errors&amp;quot; role=&amp;quot;alert&amp;quot;&amp;gt;
    &amp;lt;h3&amp;gt;Form Errors:&amp;lt;/h3&amp;gt;
    &amp;lt;ul&amp;gt;
      @for (error of getAllFormErrors(); track error) {
        &amp;lt;li&amp;gt;{{ error }}&amp;lt;/li&amp;gt;
      }
    &amp;lt;/ul&amp;gt;
  &amp;lt;/div&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;This is particularly useful for longer forms where you want to provide a summary of all errors at the top, making it easier for users to see everything that needs fixing at a glance.&lt;br&gt;&lt;h3 id=&quot;real-time-form-state-visualization&quot;&gt;&lt;a href=&quot;#real-time-form-state-visualization&quot; class=&quot;header-anchor&quot;&gt;Real-Time Form State Visualization&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;For development and debugging, you can easily display the current form state:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;html&quot; id=&quot;code-1795777174520-rkxqci0n4&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;html&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;div class=&amp;quot;form-info&amp;quot;&amp;gt;
  &amp;lt;h2&amp;gt;Form State&amp;lt;/h2&amp;gt;
  &amp;lt;div class=&amp;quot;info-grid&amp;quot;&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;strong&amp;gt;Name:&amp;lt;/strong&amp;gt; {{ personForm.name().value() }}&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;strong&amp;gt;Age:&amp;lt;/strong&amp;gt; {{ personForm.age().value() }}&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;strong&amp;gt;Name Valid:&amp;lt;/strong&amp;gt; {{ personForm.name().valid() }}&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;strong&amp;gt;Age Valid:&amp;lt;/strong&amp;gt; {{ personForm.age().valid() }}&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;strong&amp;gt;Name Touched:&amp;lt;/strong&amp;gt; {{ personForm.name().touched() }}&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;strong&amp;gt;Age Touched:&amp;lt;/strong&amp;gt; {{ personForm.age().touched() }}&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;strong&amp;gt;Name Dirty:&amp;lt;/strong&amp;gt; {{ personForm.name().dirty() }}&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;strong&amp;gt;Age Dirty:&amp;lt;/strong&amp;gt; {{ personForm.age().dirty() }}&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;strong&amp;gt;Name Pending:&amp;lt;/strong&amp;gt; {{ personForm.name().pending() }}&amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Every field in your form tree has signals for:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;value()&lt;/code&gt; - The current field value&lt;/li&gt;
&lt;li&gt;&lt;code&gt;valid()&lt;/code&gt; / &lt;code&gt;invalid()&lt;/code&gt; - Validation state&lt;/li&gt;
&lt;li&gt;&lt;code&gt;touched()&lt;/code&gt; - Has the user focused/blurred this field?&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dirty()&lt;/code&gt; - Has the user changed the value?&lt;/li&gt;
&lt;li&gt;&lt;code&gt;pending()&lt;/code&gt; - Is async validation currently running?&lt;/li&gt;
&lt;li&gt;&lt;code&gt;errors()&lt;/code&gt; - Array of validation errors&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;This makes debugging forms a breeze. You can instantly see exactly what state your form is in.&lt;br&gt;&lt;h2 id=&quot;advanced-features&quot;&gt;&lt;a href=&quot;#advanced-features&quot; class=&quot;header-anchor&quot;&gt;Advanced Features&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Now let&apos;s dive into some of the more advanced capabilities of Signal Forms.&lt;br&gt;&lt;h3 id=&quot;custom-validation-logic&quot;&gt;&lt;a href=&quot;#custom-validation-logic&quot; class=&quot;header-anchor&quot;&gt;Custom Validation Logic&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The &lt;code&gt;validate()&lt;/code&gt; function gives you complete control over validation logic. Here&apos;s the age validator from my demo:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174520-7w6jl3l4z&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;validate(schemaPath.age, ({ value }) =&amp;gt; {
  if (value() &amp;lt; 0) {
    return {
      kind: &amp;#x27;age-error&amp;#x27;,
      message: &amp;#x27;Age must be non-negative&amp;#x27;,
    };
  }

  if (value() &amp;lt; 18 || value() &amp;gt; 65) {
    return null; // Valid
  }

  return {
    kind: &amp;#x27;age-error&amp;#x27;,
    message: &amp;#x27;Age must be between lower than 18 or higher than 65&amp;#x27;,
  };
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;This validator has some interesting logic: the age must be either under 18 or over 65 (yes, it&apos;s a bit contrived for demo purposes, but it shows the flexibility). &lt;/p&gt;&lt;p&gt;The key things to note:
&lt;ol&gt;
&lt;li&gt;You receive the field&apos;s value as a &lt;strong&gt;signal&lt;/strong&gt;, so you call &lt;code&gt;value()&lt;/code&gt; to read it&lt;/li&gt;
&lt;li&gt;Return &lt;code&gt;null&lt;/code&gt; for valid values&lt;/li&gt;
&lt;li&gt;Return an error object with a &lt;code&gt;kind&lt;/code&gt; and &lt;code&gt;message&lt;/code&gt; for invalid values&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;kind&lt;/code&gt; field lets you categorize errors if needed&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;You can write any validation logic you want—async validators, cross-field validation, whatever your application needs.&lt;br&gt;&lt;h3 id=&quot;async-validation&quot;&gt;&lt;a href=&quot;#async-validation&quot; class=&quot;header-anchor&quot;&gt;Async Validation&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;One of the most powerful features of Signal Forms is built-in support for asynchronous validation. This is perfect for scenarios where you need to validate against a backend API, like checking if a username is available.&lt;/p&gt;&lt;p&gt;Signal Forms provides &lt;code&gt;validateHttp&lt;/code&gt; for HTTP-based async validation:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174520-ocpk9thub&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { form, Field, required, validateHttp } from &amp;#x27;@angular/forms/signals&amp;#x27;;

userModel = signal({
  username: &amp;#x27;&amp;#x27;,
  email: &amp;#x27;&amp;#x27;
});

userForm = form(this.userModel, (schemaPath) =&amp;gt; {
  required(schemaPath.username, { message: &amp;#x27;Username is required&amp;#x27; });
  
  // Async validation with HTTP request
  validateHttp(schemaPath.username, {
    request: ({value}) =&amp;gt; {
      const usernameValue = value();
      // Skip HTTP validation if username is empty (required validator handles this)
      if (!usernameValue || usernameValue.trim() === &amp;#x27;&amp;#x27;) {
        return undefined;
      }
      return `/api/check-username?username=${encodeURIComponent(usernameValue)}`;
    },
    onSuccess: (response: any) =&amp;gt; {
      if (response.taken) {
        return [
          {
            kind: &amp;#x27;usernameTaken&amp;#x27;,
            message: &amp;#x27;Username is already taken&amp;#x27;,
          }
        ];
      }
      return []; // Username is available - return empty array for valid
    },
    onError: (error: unknown) =&amp;gt; [
      {
        kind: &amp;#x27;networkError&amp;#x27;,
        message: &amp;#x27;Could not verify username availability&amp;#x27;,
      }
    ],
  });
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Let me break down what&apos;s happening:&lt;/p&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;request&lt;/strong&gt;: A function that returns the API endpoint URL string, or &lt;code&gt;undefined&lt;/code&gt; to skip validation. You can use the field&apos;s &lt;code&gt;value()&lt;/code&gt; signal to build dynamic URLs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;onSuccess&lt;/strong&gt;: Handle the successful response. Return an empty array &lt;code&gt;[]&lt;/code&gt; if valid, or an array of error objects if invalid&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;onError&lt;/strong&gt;: Handle network errors or exceptions. Return an array of error objects. This ensures your form handles connectivity issues gracefully&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;Showing Pending State&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;While async validation runs, the field&apos;s &lt;code&gt;pending()&lt;/code&gt; signal returns true. Use this to show loading indicators and provide feedback to users:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;html&quot; id=&quot;code-1795777174520-j7e7m0aec&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;html&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;div class=&amp;quot;form-group&amp;quot;&amp;gt;
  &amp;lt;label for=&amp;quot;username-input&amp;quot;&amp;gt;
    Username:
    &amp;lt;input
      id=&amp;quot;username-input&amp;quot;
      type=&amp;quot;text&amp;quot;
      [field]=&amp;quot;userForm.username&amp;quot;
      [attr.aria-invalid]=&amp;quot;
        userForm.username().touched() &amp;amp;&amp;amp; !userForm.username().pending()
          ? (userForm.username().invalid() ? &amp;#x27;true&amp;#x27; : &amp;#x27;false&amp;#x27;)
          : null
      &amp;quot;
      [attr.aria-valid]=&amp;quot;
        userForm.username().touched() &amp;amp;&amp;amp; userForm.username().valid() &amp;amp;&amp;amp; !userForm.username().pending() ? &amp;#x27;true&amp;#x27; : null
      &amp;quot;
      [attr.aria-busy]=&amp;quot;userForm.username().pending() ? &amp;#x27;true&amp;#x27; : null&amp;quot;
      [attr.aria-label]=&amp;quot;
        userForm.username().pending()
          ? &amp;#x27;Username (validating)&amp;#x27;
          : &amp;#x27;Username&amp;#x27;
      &amp;quot;
      [attr.aria-describedby]=&amp;quot;
        userForm.username().touched()
          ? (userForm.username().pending()
              ? &amp;#x27;username-pending&amp;#x27;
              : userForm.username().invalid()
              ? &amp;#x27;username-errors&amp;#x27;
              : null)
          : null
      &amp;quot;
    /&amp;gt;
  &amp;lt;/label&amp;gt;
  
  @if (userForm.username().touched()) {
    @if (userForm.username().pending()) {
      &amp;lt;div id=&amp;quot;username-pending&amp;quot; class=&amp;quot;pending-message&amp;quot; role=&amp;quot;status&amp;quot; aria-live=&amp;quot;polite&amp;quot; aria-label=&amp;quot;Validation in progress&amp;quot;&amp;gt;
        &amp;lt;span class=&amp;quot;spinner&amp;quot; aria-hidden=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;
        Checking availability...
      &amp;lt;/div&amp;gt;
    }
    @if (userForm.username().invalid() &amp;amp;&amp;amp; !userForm.username().pending()) {
      &amp;lt;ul id=&amp;quot;username-errors&amp;quot; class=&amp;quot;error-list&amp;quot; role=&amp;quot;alert&amp;quot; aria-live=&amp;quot;polite&amp;quot;&amp;gt;
        @for (error of userForm.username().errors(); track error) {
          &amp;lt;li&amp;gt;{{ error.message }}&amp;lt;/li&amp;gt;
        }
      &amp;lt;/ul&amp;gt;
    }
  }
  
  @if (userForm.username().valid() &amp;amp;&amp;amp; userForm.username().touched() &amp;amp;&amp;amp; !userForm.username().pending()) {
    &amp;lt;span class=&amp;quot;success&amp;quot;&amp;gt;✓ Username is available&amp;lt;/span&amp;gt;
  }
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;The &lt;code&gt;pending()&lt;/code&gt; signal makes it easy to show different UI states:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pending&lt;/strong&gt;: Show a spinner or &quot;Checking...&quot; message with &lt;code&gt;aria-busy=&quot;true&quot;&lt;/code&gt; and appropriate ARIA labels&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Invalid&lt;/strong&gt;: Show error messages with proper &lt;code&gt;aria-invalid&lt;/code&gt; and &lt;code&gt;aria-describedby&lt;/code&gt; attributes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Valid&lt;/strong&gt;: Show a success checkmark&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;This creates a smooth user experience where users get immediate feedback as the async validation runs. The comprehensive ARIA attributes ensure screen readers are properly informed about the validation state, making the form accessible to all users.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Debouncing Async Validation&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;For a better user experience, you might want to debounce async validation so it doesn&apos;t fire on every keystroke. Use the &lt;code&gt;debounce&lt;/code&gt; function as a separate call before &lt;code&gt;validateHttp&lt;/code&gt;:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174520-1wzmqwh9w&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { form, Field, required, validateHttp, debounce } from &amp;#x27;@angular/forms/signals&amp;#x27;;

userForm = form(this.userModel, (schemaPath) =&amp;gt; {
  required(schemaPath.username, { message: &amp;#x27;Username is required&amp;#x27; });
  
  // Debounce the username field to delay validation until user stops typing
  debounce(schemaPath.username, 500); // Wait 500ms after user stops typing
  
  // Async validation with HTTP request
  validateHttp(schemaPath.username, {
    request: ({value}) =&amp;gt; {
      const usernameValue = value();
      if (!usernameValue || usernameValue.trim() === &amp;#x27;&amp;#x27;) {
        return undefined;
      }
      return `/api/check-username?username=${encodeURIComponent(usernameValue)}`;
    },
    onSuccess: (response: any) =&amp;gt; {
      if (response.taken) {
        return [
          {
            kind: &amp;#x27;usernameTaken&amp;#x27;,
            message: &amp;#x27;Username is already taken&amp;#x27;,
          }
        ];
      }
      return []; // Username is available
    },
    onError: (error: unknown) =&amp;gt; [
      {
        kind: &amp;#x27;networkError&amp;#x27;,
        message: &amp;#x27;Could not verify username availability&amp;#x27;,
      }
    ],
  });
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;The &lt;code&gt;debounce&lt;/code&gt; function prevents excessive API calls while the user is still typing, making your application more efficient and user-friendly.&lt;br&gt;&lt;h3 id=&quot;form-state-tracking&quot;&gt;&lt;a href=&quot;#form-state-tracking&quot; class=&quot;header-anchor&quot;&gt;Form State Tracking&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Signal Forms track multiple types of state for each field:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Valid/Invalid&lt;/strong&gt;: Based on your validators&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Touched&lt;/strong&gt;: True after the user focuses and blurs the field&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dirty&lt;/strong&gt;: True after the user changes the value&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pristine&lt;/strong&gt;: The opposite of dirty&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;You can also check the state of the entire form:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;html&quot; id=&quot;code-1795777174520-he3q5c55j&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;html&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;button type=&amp;quot;submit&amp;quot; [disabled]=&amp;quot;personForm().invalid()&amp;quot;&amp;gt;
  Submit
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Notice &lt;code&gt;personForm()&lt;/code&gt; with parentheses—the form itself is a signal! This is brilliant because it means the button&apos;s disabled state automatically updates whenever any field&apos;s validation state changes.&lt;br&gt;&lt;h3 id=&quot;onpush-change-detection&quot;&gt;&lt;a href=&quot;#onpush-change-detection&quot; class=&quot;header-anchor&quot;&gt;OnPush Change Detection&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Here&apos;s something that makes Signal Forms especially powerful: they work seamlessly with OnPush change detection.&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174520-vsmubkpos&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;@Component({
  selector: &amp;#x27;app-root&amp;#x27;,
  imports: [RouterOutlet, Field],
  templateUrl: &amp;#x27;./app.html&amp;#x27;,
  styleUrl: &amp;#x27;./app.scss&amp;#x27;,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class App {
  // ... form code ...
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;With traditional reactive forms and OnPush, you often need to manually trigger change detection or use RxJS observables with the async pipe. Signal Forms &quot;just work&quot; because signals automatically notify Angular when they change. This means better performance with zero extra effort.&lt;br&gt;&lt;h2 id=&quot;data-flow-architecture&quot;&gt;&lt;a href=&quot;#data-flow-architecture&quot; class=&quot;header-anchor&quot;&gt;Data Flow Architecture&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Understanding how data flows through Signal Forms helps you use them effectively. Here&apos;s the complete picture:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Initialization Flow:&lt;/strong&gt; &lt;div class=&quot;code-block-container&quot; data-language=&quot;plaintext&quot; id=&quot;code-1795777174520-snqpruv5o&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;plaintext&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;personModel (signal) → form() → personForm (FieldTree with signals)
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;strong&gt;User Input Flow:&lt;/strong&gt; &lt;div class=&quot;code-block-container&quot; data-language=&quot;plaintext&quot; id=&quot;code-1795777174520-j4aabd5k7&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;plaintext&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;User types → [field] directive → field signal updates → personModel signal updates → UI reflects changes
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;strong&gt;Validation Flow:&lt;/strong&gt; &lt;div class=&quot;code-block-container&quot; data-language=&quot;plaintext&quot; id=&quot;code-1795777174520-oqiet7s5c&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;plaintext&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;Field value changes → validators run → valid/invalid signals update → template updates
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;strong&gt;Form Submission:&lt;/strong&gt; &lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174520-9f1868uuj&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;onSubmit(event: Event) {
  event.preventDefault();
  const person = this.personModel();
  console.log(&amp;#x27;Submitted person:&amp;#x27;, person);
  // e.g., send person to an API or service
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;The beautiful part is that you always have direct access to your model through the signal. No need to call &lt;code&gt;form.value&lt;/code&gt; or deal with partial values—just read the signal and you have your complete, typed data.&lt;br&gt;&lt;h2 id=&quot;comparison-with-traditional-forms&quot;&gt;&lt;a href=&quot;#comparison-with-traditional-forms&quot; class=&quot;header-anchor&quot;&gt;Comparison with Traditional Forms&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let me show you what the same form would look like with Reactive Forms:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Reactive Forms Version:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174520-yc0ax3jtd&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// Component
personForm = new FormGroup({
  name: new FormControl(&amp;#x27;&amp;#x27;, [Validators.required]),
  age: new FormControl(0, [Validators.required, this.ageValidator])
});

ageValidator(control: AbstractControl): ValidationErrors | null {
  const value = control.value;
  if (value &amp;lt; 0) {
    return { ageError: &amp;#x27;Age must be non-negative&amp;#x27; };
  }
  if (value &amp;gt;= 18 &amp;amp;&amp;amp; value &amp;lt;= 65) {
    return { ageError: &amp;#x27;Age must be lower than 18 or higher than 65&amp;#x27; };
  }
  return null;
}

onSubmit() {
  const person: Person = this.personForm.value;
  console.log(&amp;#x27;Submitted person:&amp;#x27;, person);
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;html&quot; id=&quot;code-1795777174521-o5scgav7u&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;html&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;!-- Template --&amp;gt;
&amp;lt;form [formGroup]=&amp;quot;personForm&amp;quot; (submit)=&amp;quot;onSubmit()&amp;quot;&amp;gt;
  &amp;lt;input formControlName=&amp;quot;name&amp;quot; /&amp;gt;
  &amp;lt;div *ngIf=&amp;quot;personForm.get(&amp;#x27;name&amp;#x27;)?.invalid &amp;amp;&amp;amp; personForm.get(&amp;#x27;name&amp;#x27;)?.touched&amp;quot;&amp;gt;
    &amp;lt;div *ngFor=&amp;quot;let error of personForm.get(&amp;#x27;name&amp;#x27;)?.errors | keyvalue&amp;quot;&amp;gt;
      {{ error.value }}
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;!-- More template code... --&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;strong&gt;Signal Forms Version:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174521-0bwc68bxz&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// Component
personModel = signal&amp;lt;Person&amp;gt;({ name: &amp;#x27;&amp;#x27;, age: 0 });

personForm = form(this.personModel, (schemaPath) =&amp;gt; {
  required(schemaPath.name, { message: &amp;#x27;Name is required&amp;#x27; });
  required(schemaPath.age, { message: &amp;#x27;Age is required&amp;#x27; });
  validate(schemaPath.age, ({ value }) =&amp;gt; {
    if (value() &amp;lt; 0) {
      return { kind: &amp;#x27;age-error&amp;#x27;, message: &amp;#x27;Age must be non-negative&amp;#x27; };
    }
    if (value() &amp;lt; 18 || value() &amp;gt; 65) return null;
    return { kind: &amp;#x27;age-error&amp;#x27;, message: &amp;#x27;Age must be lower than 18 or higher than 65&amp;#x27; };
  });
});

onSubmit(event: Event) {
  event.preventDefault();
  const person = this.personModel();
  console.log(&amp;#x27;Submitted person:&amp;#x27;, person);
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;html&quot; id=&quot;code-1795777174521-myd0v9twx&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;html&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;!-- Template --&amp;gt;
&amp;lt;form (submit)=&amp;quot;onSubmit($event)&amp;quot;&amp;gt;
  &amp;lt;input [field]=&amp;quot;personForm.name&amp;quot; /&amp;gt;
  @if (personForm.name().touched() &amp;amp;&amp;amp; personForm.name().invalid()) {
    &amp;lt;ul&amp;gt;
      @for (error of personForm.name().errors(); track error) {
        &amp;lt;li&amp;gt;{{ error.message }}&amp;lt;/li&amp;gt;
      }
    &amp;lt;/ul&amp;gt;
  }
  &amp;lt;!-- More template code... --&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;The differences are striking:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Less boilerplate&lt;/strong&gt;: No &lt;code&gt;FormGroup&lt;/code&gt;, &lt;code&gt;FormControl&lt;/code&gt;, or &lt;code&gt;Validators&lt;/code&gt; imports&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Better type safety&lt;/strong&gt;: The schema path is fully typed from your model&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cleaner templates&lt;/strong&gt;: &lt;code&gt;[field]&lt;/code&gt; instead of &lt;code&gt;[formGroup]&lt;/code&gt; + &lt;code&gt;formControlName&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;More intuitive&lt;/strong&gt;: Error messages are objects with a message property, not string keys&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Direct model access&lt;/strong&gt;: Just read the signal, no need to extract values from the form&lt;/li&gt;
&lt;/ul&gt; &lt;h2 id=&quot;benefits-and-considerations&quot;&gt;&lt;a href=&quot;#benefits-and-considerations&quot; class=&quot;header-anchor&quot;&gt;Benefits and Considerations&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;After working with Signal Forms for a while, here&apos;s my honest assessment:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Type Safety&lt;/strong&gt;: TypeScript knows your form structure from your model interface. Typos and missing fields are caught at compile time.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Less Boilerplate&lt;/strong&gt;: No more creating &lt;code&gt;FormControl&lt;/code&gt; instances or setting up &lt;code&gt;FormGroup&lt;/code&gt; hierarchies. Just define your model and validators.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Better Performance&lt;/strong&gt;: Signals provide fine-grained reactivity, and OnPush change detection works automatically.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Intuitive API&lt;/strong&gt;: Reading values, checking validity, displaying errors—everything uses signals with a consistent API.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Modern Angular Patterns&lt;/strong&gt;: Works great with standalone components, the new control flow syntax, and modern Angular best practices.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Readable Code&lt;/strong&gt;: The declarative style makes it obvious what your form does just by reading the code.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;Considerations:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;New API to Learn&lt;/strong&gt;: If your team is comfortable with Reactive Forms, there&apos;s a learning curve.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Angular 21+ Required&lt;/strong&gt;: You need to be on the latest Angular version, which might not be feasible for all projects.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Ecosystem Maturity&lt;/strong&gt;: As a newer API, there aren&apos;t as many examples, third-party libraries, or Stack Overflow answers yet.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Migration Path&lt;/strong&gt;: Converting existing reactive forms isn&apos;t automatic—you&apos;ll need to rewrite them.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Advanced Scenarios&lt;/strong&gt;: For very complex forms with dynamic fields, conditional validators, or form arrays, the patterns are still being established by the community.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;That said, for new projects or new forms in existing projects, I&apos;d definitely reach for Signal Forms first.&lt;br&gt;&lt;h2 id=&quot;practical-implementation-tips&quot;&gt;&lt;a href=&quot;#practical-implementation-tips&quot; class=&quot;header-anchor&quot;&gt;Practical Implementation Tips&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Here are some tips I&apos;ve learned while working with Signal Forms:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;1. Structure Your Models&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Keep your form models separate from your domain models if they have different shapes:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174521-j7yd26g27&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// Domain model from API
interface User {
  id: string;
  firstName: string;
  lastName: string;
  email: string;
}

// Form model
interface UserForm {
  firstName: string;
  lastName: string;
  email: string;
}

userFormModel = signal&amp;lt;UserForm&amp;gt;({
  firstName: &amp;#x27;&amp;#x27;,
  lastName: &amp;#x27;&amp;#x27;,
  email: &amp;#x27;&amp;#x27;
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;strong&gt;2. Centralize Validators&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;For validators you&apos;ll reuse across multiple forms, create a validators utility file:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174521-mterjfcqv&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// validators.ts
export const emailValidator = ({ value }) =&amp;gt; {
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  return emailRegex.test(value()) 
    ? null 
    : { kind: &amp;#x27;email&amp;#x27;, message: &amp;#x27;Please enter a valid email address&amp;#x27; };
};

// In your component
validate(schemaPath.email, emailValidator);
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;strong&gt;3. Display Errors Consistently&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Create a reusable error component for consistent error display:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174521-127riyvhr&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// field-errors.component.ts
@Component({
  selector: &amp;#x27;app-field-errors&amp;#x27;,
  template: `
    @if (field().touched() &amp;amp;&amp;amp; field().invalid()) {
      &amp;lt;ul class=&amp;quot;error-list&amp;quot; role=&amp;quot;alert&amp;quot; aria-live=&amp;quot;polite&amp;quot;&amp;gt;
        @for (error of field().errors(); track error) {
          &amp;lt;li&amp;gt;{{ error.message }}&amp;lt;/li&amp;gt;
        }
      &amp;lt;/ul&amp;gt;
    }
  `
})
export class FieldErrorsComponent {
  field = input.required&amp;lt;FieldSignal&amp;gt;();
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;strong&gt;4. Handle Form Submission&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Always prevent default form submission and check validity:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174521-3awx8b9qw&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;onSubmit(event: Event) {
  event.preventDefault();
  
  if (this.personForm().invalid()) {
    // Mark all fields as touched to show errors
    // (This is a feature that should be added to the API)
    return;
  }
  
  const data = this.personModel();
  // Submit data to API
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;header-anchor&quot;&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Signal Forms represent a significant step forward for Angular forms. They embrace modern Angular patterns—signals, standalone components, the new control flow syntax—and deliver a developer experience that&apos;s both more intuitive and more powerful than what came before.&lt;/p&gt;&lt;p&gt;I&apos;ve been working with Angular for years now, and forms have always been one of those areas where I felt the framework could do better. Template-driven forms were too magical, and Reactive Forms were too verbose. Signal Forms hit a sweet spot: they&apos;re explicit enough to be testable and maintainable, but concise enough that you don&apos;t drown in boilerplate.&lt;/p&gt;&lt;p&gt;The type safety is what really seals the deal for me. Having TypeScript catch form-related errors at compile time instead of runtime is huge. And the way signals integrate with OnPush change detection means you get better performance without having to think about it.&lt;/p&gt;&lt;p&gt;If you&apos;re starting a new Angular 21 project, I&apos;d say Signal Forms should be your default choice. For existing applications, evaluate on a case-by-case basis—new features might be a good opportunity to try Signal Forms, while existing forms might not be worth rewriting immediately.&lt;/p&gt;&lt;p&gt;The Angular team continues to iterate on this API, so I expect it to mature quickly as more developers adopt it and provide feedback. I&apos;m excited to see where this goes!&lt;/p&gt;&lt;p&gt;Want to try it yourself? Check out my demo project on GitHub: &lt;a href=&quot;https://github.com/Nergy101/SignalFormsDemo&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;SignalFormsDemo&lt;/a&gt; (or wherever you&apos;ve hosted it).&lt;/p&gt;&lt;p&gt;And as always, feel free to reach out if you have questions or want to chat about Angular!&lt;/p&gt;&lt;p&gt;&lt;hr&gt;&lt;/p&gt;&lt;p&gt;Last updated: 2026-01-28
            &lt;/div&gt;</content>
  </entry>
  <entry>
    <title>PocketBase and Angular</title>
    <link href="https://blog.nergy.space/blogs/pocketbase-and-angular"/>
    <id>https://blog.nergy.space/blogs/pocketbase-and-angular</id>
    <published>2025-11-25T00:00:00.000Z</published>
    <updated>2025-11-25T00:00:00.000Z</updated>
    <author><name>Christian / Nergy101</name></author>
    <summary>The combination of PocketBase and Angular is my personal favorite for fast prototyping and hobbying. What makes PocketBase stand out is how it manages to pack enterprise-grade features into a single executable while keeping the developer experience refreshingly simple. You get a complete backend…</summary>
    <content type="html">&lt;div class=&quot;container&quot;&gt;
                &lt;h1 id=&quot;pocketbase-angular&quot;&gt;&lt;a href=&quot;#pocketbase-angular&quot; class=&quot;header-anchor&quot;&gt;PocketBase &amp; Angular&lt;/a&gt;&lt;/h1&gt;&lt;p&gt;The combination of &lt;a href=&quot;https://pocketbase.io&quot; target=&quot;&lt;em&gt;blank&quot; rel=&quot;noopener noreferrer&quot;&gt;PocketBase&lt;/a&gt; and &lt;a href=&quot;https://angular.io&quot; target=&quot;&lt;/em&gt;blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Angular&lt;/a&gt; is my personal favorite for fast prototyping and hobbying. What makes PocketBase stand out is how it manages to pack enterprise-grade features into a single executable while keeping the developer experience refreshingly simple. You get a complete backend solution that feels like it was built by developers who actually understand the pain points of modern web development.&lt;/p&gt;&lt;p&gt;Of all &lt;a href=&quot;#what-is-a-baas&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;BaaS&lt;/a&gt; offerings, PocketBase is my favorite because it delivers everything you need without the typical BaaS headaches:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Easy to use, with a good JavaScript SDK (and Flutter SDK) that makes integration seamless&lt;/li&gt;
&lt;li&gt;Being actively developed on &lt;a href=&quot;https://github.com/pocketbase/pocketbase&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;GitHub&lt;/a&gt; with a responsive community&lt;/li&gt;
&lt;li&gt;Easy to follow OAuth configuration pages for Google, GitHub and Microsoft. No more wrestling with cryptic OAuth setups 🥳🎉&lt;/li&gt;
&lt;li&gt;Simple table management with relational fields and an intuitive UI that makes schema design feel natural&lt;/li&gt;
&lt;li&gt;It can do custom endpoints by writing simple JS functions, giving you the flexibility to extend functionality without leaving the ecosystem&lt;/li&gt;
&lt;li&gt;You can hook-in on events like &apos;beforeCreate&apos;, &apos;beforeUpdate&apos;, &apos;beforeDelete&apos;, &apos;afterCreate&apos;, &apos;afterUpdate&apos;, &apos;afterDelete&apos;, etc. to do custom logic when you want to do something custom.&lt;/li&gt;
&lt;li&gt;It can do CRUD + live-view subscriptions on data, so real-time features come built-in&lt;/li&gt;
&lt;li&gt;Easy to host (yourself or hosted for free by &lt;a href=&quot;https://pockethost.io/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;PocketHost&lt;/a&gt;), deploy it anywhere, from your Raspberry Pi to a managed service&lt;/li&gt;
&lt;li&gt;And the best part? &lt;strong&gt;It&apos;s completely free&lt;/strong&gt;. All of these features, and it costs you nothing&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;And &lt;a href=&quot;https://angular.io&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Angular&lt;/a&gt; is my favorite because well... I&apos;ve worked with it for years.&lt;br&gt;It&apos;s a great framework for building web applications. It continually evolves with new trends, like using Signals, Vite, and more. It has stood the test of time and is used a lot in enterprise applications.&lt;br&gt;&lt;h2 id=&quot;table-of-contents&quot;&gt;&lt;a href=&quot;#table-of-contents&quot; class=&quot;header-anchor&quot;&gt;Table of Contents&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#pocketbase--angular&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;PocketBase &amp; Angular&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#what-is-a-baas&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;What is a BaaS?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#introduction-to-pocketbase&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Introduction to PocketBase&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#getting-started-with-pocketbase&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Getting Started with PocketBase&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#basic-javascript-sdk-usage&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Basic JavaScript SDK Usage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#typed-pocketbase-angular-service&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Typed PocketBase Angular Service&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#downsides-to-using-pocketbase&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Downsides to using PocketBase&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#conclusion&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;h2 id=&quot;what-is-a-baas&quot;&gt;&lt;a href=&quot;#what-is-a-baas&quot; class=&quot;header-anchor&quot;&gt;What is a BaaS?&lt;/a&gt;&lt;/h2&gt; A BaaS is a &apos;backend as a service&apos;. These offerings usually provide a storage mechanism (database), authentication through OAuth and other means, and other services for your application. They are usually very easy to get started with, and very easy to use.&lt;/p&gt;&lt;p&gt;Just to name a few:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://firebase.google.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Firebase&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://supabase.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Supabase&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://appwrite.io/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Appwrite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.convex.dev/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Convex&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://aws.amazon.com/amplify/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;AWS Amplify&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The list goes on and on and on&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Today we will dive into &lt;a href=&quot;https://pocketbase.io&quot; target=&quot;&lt;em&gt;blank&quot; rel=&quot;noopener noreferrer&quot;&gt;PocketBase&lt;/a&gt; and why I have been using it to build &lt;a href=&quot;https://tovedem.nergy.space&quot; target=&quot;&lt;/em&gt;blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Tovedem&lt;/a&gt;, rather rapidly and carefree in combination with &lt;a href=&quot;https://angular.io&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Angular&lt;/a&gt;.&lt;br&gt;So this blog will go over the basics of &lt;a href=&quot;#introduction-to-pocketbase&quot; target=&quot;&lt;em&gt;blank&quot; rel=&quot;noopener noreferrer&quot;&gt;PocketBase&lt;/a&gt;, &lt;a href=&quot;#getting-started-with-pocketbase&quot; target=&quot;&lt;/em&gt;blank&quot; rel=&quot;noopener noreferrer&quot;&gt;how to get started&lt;/a&gt;, &lt;a href=&quot;#basic-javascript-sdk-usage&quot; target=&quot;&lt;em&gt;blank&quot; rel=&quot;noopener noreferrer&quot;&gt;how to use the JavaScript SDK&lt;/a&gt;, and how to use PocketBase with &lt;a href=&quot;#typed-pocketbase-angular-service&quot; target=&quot;&lt;/em&gt;blank&quot; rel=&quot;noopener noreferrer&quot;&gt;a typed service in Angular&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;This combination of PocketBase and Angular has been a great experience and I have been able to build a lot of features quickly and easily. Definitely worth a try for quick (hobby-)projects or prototypes.&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;introduction-to-pocketbase&quot;&gt;&lt;a href=&quot;#introduction-to-pocketbase&quot; class=&quot;header-anchor&quot;&gt;Introduction to PocketBase&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;First off, what &lt;strong&gt;is&lt;/strong&gt; PocketBase?&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://pocketbase.io&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;PocketBase&lt;/a&gt; is a backend service in a single file. It&apos;s being built as a framework in Go with a SQLite database backing. As said it is available to use as a framework, but not only that. It&apos;s also available as a database + backend application that encompasses most of the basic development work. Think of authentication (O-Auth), managing SQL tables with different relationships, APIs on this data, and real-time feeds.&lt;/p&gt;&lt;p&gt;Check out the &lt;a href=&quot;https://pocketbase.io/demo/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;PocketBase demo&lt;/a&gt; to get a feel for what PocketBase is capable of and what the UI looks like.&lt;/p&gt;&lt;p&gt;Another thing; The documentation is GREAT! While extending PocketBase functionality with custom Javascript endpoints, etc. the documentation has always been up-to-date and very searchable. The docs are easy to follow and understand, and breaking changes are well-documented and easy to follow.&lt;br&gt;&lt;h2 id=&quot;getting-started-with-pocketbase&quot;&gt;&lt;a href=&quot;#getting-started-with-pocketbase&quot; class=&quot;header-anchor&quot;&gt;Getting Started with PocketBase&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let&apos;s have a quick look at how to get started with PocketBase.&lt;/p&gt;&lt;p&gt;Self-host in your preferred way, either with Docker or simply by running the executable. Then visit &lt;code&gt;localhost:8090/_/&lt;/code&gt; to be visited by the dashboard. Within this dashboard, we can manage the authentication providers, database schema, the data inside, logging, and different kinds of settings.&lt;/p&gt;&lt;p&gt;Don&apos;t want to self-host? Use &lt;a href=&quot;https://pockethost.io/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;PocketHost&lt;/a&gt; for a managed PocketBase experience that keeps the zero-config feel without managing servers yourself. Of course you still get full access to all the features of PocketBase.&lt;/p&gt;&lt;p&gt;Managing your data schema is really easy and visual, just add the fields you want for a collection, and you&apos;re done! Notice how there are some complex types you can add easily like rich text editor texts, emails, and whole files. Also, take special mention of the &apos;relation&apos; type which allows for configuring 1-n or n-1 or 1-1 relationships between different collections.&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;readable-image&quot;&gt; &lt;figure&gt; &lt;div class=&quot;image-scroll&quot;&gt; &lt;img src=&quot;https://blog.nergy.space/assets/pocketbase/image.jpeg&quot; alt=&quot;PocketBase dashboard showing device_comments collection from retroranker.site&quot; /&gt;     &lt;/div&gt;    &lt;figcaption&gt;      Screenshot from the PocketBase instance for &lt;a href=&quot;https://retroranker.site&quot; target=&quot;_blank&quot;&gt;retroranker.site&lt;/a&gt; showing the PocketBase dashboard with the &lt;code&gt;device comments&lt;/code&gt; collection. Notice how relational fields (like &lt;code&gt;user&lt;/code&gt; and &lt;code&gt;device&lt;/code&gt;) display readable names like &quot;nergy101&quot; instead of string IDs, making it much easier to work with your data in the admin interface.     &lt;/figcaption&gt; &lt;/figure&gt;
&lt;/div&gt;&lt;h2 id=&quot;basic-javascript-sdk-usage&quot;&gt;&lt;a href=&quot;#basic-javascript-sdk-usage&quot; class=&quot;header-anchor&quot;&gt;Basic JavaScript SDK Usage&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Once you have your PocketBase instance running, you can easily interact with it using the JavaScript SDK. Here&apos;s a quick example:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;javascript&quot; id=&quot;code-1795777174486-rac988y83&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;javascript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;import PocketBase from &amp;quot;pocketbase&amp;quot;;

// Initialize the client
const pb = new PocketBase(&amp;quot;http://127.0.0.1:8090&amp;quot;);

// Authenticate a user
const authData = await pb
  .collection(&amp;quot;users&amp;quot;)
  .authWithPassword(&amp;quot;test@example.com&amp;quot;, &amp;quot;1234567890&amp;quot;);

// Create a new record
const data = {
  title: &amp;quot;My First Post&amp;quot;,
  content: &amp;quot;Hello PocketBase!&amp;quot;,
  author: pb.authStore.model.id,
};
const record = await pb.collection(&amp;quot;posts&amp;quot;).create(data);

// Fetch records with filtering
const records = await pb.collection(&amp;quot;posts&amp;quot;).getList(1, 20, {
  filter: &amp;#x27;created &amp;gt;= &amp;quot;2024-01-01&amp;quot;&amp;#x27;,
  sort: &amp;quot;-created&amp;quot;,
});

// Real-time subscription
pb.collection(&amp;quot;posts&amp;quot;).subscribe(&amp;quot;*&amp;quot;, function (e) {
  console.log(&amp;quot;Real-time update:&amp;quot;, e.record);
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Of course, for this to work, you need to create a collection named &lt;code&gt;posts&lt;/code&gt; in the PocketBase instance with the fields &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;content&lt;/code&gt;, and &lt;code&gt;author&lt;/code&gt;. The &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;created&lt;/code&gt;, &lt;code&gt;updated&lt;/code&gt; fields are created automatically in every collection.&lt;/p&gt;&lt;p&gt;The SDK makes it incredibly simple to handle authentication, CRUD operations, and real-time updates with just a few lines of code.&lt;br&gt;&lt;h2 id=&quot;typed-pocketbase-angular-service&quot;&gt;&lt;a href=&quot;#typed-pocketbase-angular-service&quot; class=&quot;header-anchor&quot;&gt;Typed PocketBase Angular Service&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;While building &lt;a href=&quot;https://tovedem.nergy.space&quot; target=&quot;&lt;em&gt;blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Tovedem&lt;/a&gt; I wrapped &lt;a href=&quot;#basic-javascript-sdk-usage&quot; target=&quot;&lt;/em&gt;blank&quot; rel=&quot;noopener noreferrer&quot;&gt;the SDK&lt;/a&gt; in an Angular &lt;code&gt;PocketbaseService&lt;/code&gt; that leans heavily on generics. Every helper (&lt;code&gt;create&lt;/code&gt;, &lt;code&gt;update&lt;/code&gt;, &lt;code&gt;getAll&lt;/code&gt;, &lt;code&gt;getPage&lt;/code&gt;, …) accepts a &lt;code&gt;T&lt;/code&gt; type parameter, so TypeScript keeps the rest of my code perfectly aligned with the domain models, assuming those models mirror the PocketBase collections (or at least a subset of them). This buys us a few concrete wins:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;The raw &lt;code&gt;RecordModel&lt;/code&gt; of PocketBase gets replaced with our own strongly typed models, so returned data is instantly usable and typed.&lt;/li&gt;
&lt;li&gt;IntelliSense becomes effortless because every field is now known up front.&lt;/li&gt;
&lt;li&gt;Runtime surprises drop as mismatched fields show up while coding compile-time, not only during runtime or in production.&lt;/li&gt;
&lt;li&gt;When the PocketBase schema changes, we update the corresponding interface once and the compiler flags every usage that needs attention.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Here&apos;s the relevant slice of the service (truncated for brevity) showing how every CRUD helper is typed:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174487-dvjxxc4xr&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { inject, Injectable } from &amp;quot;@angular/core&amp;quot;;
import PocketBase, { BaseModel } from &amp;quot;pocketbase&amp;quot;;
import { Environment } from &amp;quot;@/environment&amp;quot;;
import { Page } from &amp;quot;@/app/models/pocketbase/page.model&amp;quot;;

type ListOptions = { expand?: string; filter?: string; sort?: string };
type GetOptions = { expand?: string };

@Injectable({ providedIn: &amp;quot;root&amp;quot; })
export class PocketbaseService {
  private environment = inject(Environment);
  private client = new PocketBase(this.environment.pocketbase.baseUrl);

  async create&amp;lt;T&amp;gt;(collectionName: string, item: Partial&amp;lt;T&amp;gt;): Promise&amp;lt;T&amp;gt; {
    const result = await this.client.collection(collectionName).create(item);
    return result as T;
  }

  async update&amp;lt;T extends BaseModel&amp;gt;(collectionName: string, item: T): Promise&amp;lt;T&amp;gt; {
    const result = await this.client
      .collection(collectionName)
      .update(item.id, item);
      
    return result as T;
  }

  async getAll&amp;lt;T&amp;gt;(collectionName: string, options?: ListOptions): Promise&amp;lt;T[]&amp;gt; {
    const data = await this.client
      .collection(collectionName)
      .getFullList(options);

    return data as T[];
  }

  async getOne&amp;lt;T&amp;gt;(collectionName: string, id: string, options?: GetOptions): Promise&amp;lt;T&amp;gt; {
    const data = await this.client
      .collection(collectionName)
      .getOne(id, options);

    return data as T;
  }

  async getPage&amp;lt;T&amp;gt;(collectionName: string, page: number, perPage: number, options?: GetOptions): Promise&amp;lt;Page&amp;lt;T&amp;gt;&amp;gt; {
    const list = await this.client
      .collection(collectionName)
      .getList(page, perPage, options);

    return {
      ...list,
      items: list.items as T[],
    };
  }

  async delete(collectionName: string, id: string): Promise&amp;lt;boolean&amp;gt; {
    const result = await this.client.collection(collectionName).delete(id);
    return result;
  }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;The pagination helper leans on a tiny &lt;code&gt;Page&lt;/code&gt; interface:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174487-3ct3gyk53&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { ListResult } from &amp;quot;pocketbase&amp;quot;;

export interface Page&amp;lt;T&amp;gt; extends ListResult&amp;lt;T&amp;gt; {}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;(Defined in &lt;code&gt;@/app/models/pocketbase/page.model.ts&lt;/code&gt;)&lt;/p&gt;&lt;p&gt;Here&apos;s an example of a &lt;code&gt;Group&lt;/code&gt; model, a small object that represents a group of users:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174487-9el7ajgk5&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { BaseModel } from &amp;quot;pocketbase&amp;quot;;

export interface Group extends BaseModel {
  name: string;
  description?: string;
  images?: string[];
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;And here&apos;s the typed CRUD flow wired into an Angular component, it&apos;s a bit illustrative for this example but it shows the power of &lt;a href=&quot;#typed-pocketbase-angular-service&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;the typed service&lt;/a&gt; and how it can be used to build a robust application.&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174487-8cxrjpb0u&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { Component, OnInit, inject, signal, computed } from &amp;quot;@angular/core&amp;quot;;
import { PocketbaseService } from &amp;quot;@/app/shared/services/pocketbase.service&amp;quot;;
import { Group } from &amp;quot;@/app/models/domain/group.model&amp;quot;;
import { Page } from &amp;quot;@/app/models/pocketbase/page.model&amp;quot;;

@Component({
  selector: &amp;quot;app-group-admin&amp;quot;,
  templateUrl: &amp;quot;./group-admin.component.html&amp;quot;,
})
export class GroupAdminComponent implements OnInit {
  private readonly pocketbase = inject(PocketbaseService);

  readonly groups = signal&amp;lt;Group[]&amp;gt;([]);
  readonly selected = signal&amp;lt;Group | null&amp;gt;(null);
  readonly page = signal&amp;lt;Page&amp;lt;Group&amp;gt; | null&amp;gt;(null);
  readonly loading = signal(false);

  readonly totalGroups = computed(
    () =&amp;gt; this.page()?.totalItems ?? this.groups().length
  );

  async ngOnInit(): Promise&amp;lt;void&amp;gt; {
    await this.loadGroups();
  }

  async onGroupCreate(formValue: Pick&amp;lt;Group, &amp;quot;name&amp;quot; | &amp;quot;description&amp;quot;&amp;gt;) {
    const created = await this.pocketbase.create&amp;lt;Group&amp;gt;(&amp;quot;groups&amp;quot;, {
      name: formValue.name,
      description: formValue.description,
    });
    this.groups.update((list) =&amp;gt; [...list, created]);
  }

  async onGroupUpdate(group: Group) {
    const updated = await this.pocketbase.update&amp;lt;Group&amp;gt;(&amp;quot;groups&amp;quot;, group);
    this.selected.set(updated);
    await this.loadGroups();
  }

  async onGroupDelete(id: string) {
    await this.pocketbase.delete(&amp;quot;groups&amp;quot;, id);
    this.groups.update((list) =&amp;gt; list.filter((g) =&amp;gt; g.id !== id));
    if (this.selected()?.id === id) {
      this.selected.set(this.groups()[0] ?? null);
    }
  }

  async onRefreshPage(pageNumber = 1) {
    const nextPage = await this.pocketbase.getPage&amp;lt;Group&amp;gt;(
      &amp;quot;groups&amp;quot;,
      pageNumber,
      10,
      { expand: &amp;quot;members&amp;quot; }
    );
    this.page.set(nextPage);
  }

  async onSelect(id: string) {
    const group = await this.pocketbase.getOne&amp;lt;Group&amp;gt;(&amp;quot;groups&amp;quot;, id, {
      expand: &amp;quot;members&amp;quot;,
    });
    this.selected.set(group);
  }

  private async loadGroups() {
    this.loading.set(true);
    try {
      const result = await this.pocketbase.getAll&amp;lt;Group&amp;gt;(&amp;quot;groups&amp;quot;, {
        expand: &amp;quot;members&amp;quot;,
      });
      this.groups.set(result);
      if (result.length) {
        await this.onSelect(result[0].id);
      }
      await this.onRefreshPage();
    } finally {
      this.loading.set(false);
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Because every method returns &lt;code&gt;Promise&lt;/code&gt; of &lt;code&gt;T&lt;/code&gt; (or &lt;code&gt;Promise&lt;/code&gt; of &lt;code&gt;Page&lt;/code&gt; of &lt;code&gt;T&lt;/code&gt; in the pagination helpers), responses stay typed and the compiler points me to every place that needs updating whenever the schema evolves. It&apos;s a small abstraction, but it turned &lt;a href=&quot;#basic-javascript-sdk-usage&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;the PocketBase SDK&lt;/a&gt; into a first-class citizen inside Angular and made refactors far less scary.&lt;br&gt;&lt;h2 id=&quot;downsides-to-using-pocketbase&quot;&gt;&lt;a href=&quot;#downsides-to-using-pocketbase&quot; class=&quot;header-anchor&quot;&gt;Downsides to using PocketBase&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Database migrations&lt;/strong&gt; are not supported. You have to manually update the schema in the database. This includes transformations of existing data, making it difficult to make changes to the schema without losing data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Custom query language&lt;/strong&gt; might be a bit limited. You can&apos;t use SQL queries, only the PocketBase query language. This can be limiting for complex queries.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Storage space for files&lt;/strong&gt; is limited to the storage specs of where you host PocketBase. The only integration to cloud storage is S3-compatible storage.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Seperate note about &lt;strong&gt;performance&lt;/strong&gt;:
&lt;strong&gt;&lt;a href=&quot;https://pocketbase.io/faq&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Does it scale?&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The &lt;a href=&quot;https://pocketbase.io/faq&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;FAQ&lt;/a&gt; states:
&lt;blockquote&gt;Only on a single server, aka. vertical. Most of the time, you may not need the complexity of managing a fleet of machines and services just to run your backend. PocketBase could be a great choice for small and midsize applications - SaaS, mobile api backend, intranet, etc. Even without optimizations, PocketBase can easily serve 10 000+ persistent realtime connections on a cheap $4 Hetzner CAX11 VPS (2vCPU, 4GB RAM). You can find performance tests for various read&amp;write operations in the official benchmarks repo . There is still room for improvements (I haven&apos;t done extensive profiling yet), but the current performance is already good enough for the type of applications PocketBase is intended for.&lt;/blockquote&gt;&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;header-anchor&quot;&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;So why choose PocketBase over other &lt;a href=&quot;#what-is-a-baas&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;BaaS&lt;/a&gt; options like Firebase, Supabase, or Appwrite? &lt;/p&gt;&lt;p&gt;The combination of PocketBase with &lt;a href=&quot;#typed-pocketbase-angular-service&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;a typed Angular service&lt;/a&gt; gives you &lt;strong&gt;several key advantages&lt;/strong&gt;:&lt;/p&gt;&lt;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Self-hosting freedom&lt;/strong&gt;: Unlike Firebase or AWS Amplify, you can run PocketBase anywhere, on your own server, a Raspberry Pi, or use PocketHost for free managed hosting. This gives you complete control over your data and infrastructure.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Simplicity&lt;/strong&gt;: PocketBase&apos;s single-file deployment and SQLite backend mean zero configuration headaches. No complex cloud setups, no vendor lock-in, just a simple executable that works.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Type safety&lt;/strong&gt;: &lt;a href=&quot;#typed-pocketbase-angular-service&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;By wrapping the SDK in a typed service&lt;/a&gt; (as shown above), you get compile-time guarantees that catch errors before they reach production. This is especially valuable when working with rapidly evolving schemas.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cost&lt;/strong&gt;: It&apos;s completely free and open-source. While other BaaS platforms have free tiers, they often come with limitations that can bite you as you scale. For small to midsize projects, PocketBase is a great (FREE!) choice.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Developer experience&lt;/strong&gt;: The admin UI is intuitive, the documentation is excellent, and the ability to write custom endpoints and hooks in JavaScript makes it easy to extend functionality without leaving the ecosystem.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SQLite&lt;/strong&gt;: The database is SQLite, which makes it very lightweight and easy to backup, move, etc.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;The &lt;a href=&quot;#typed-pocketbase-angular-service&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;typed service pattern&lt;/a&gt; I&apos;ve shown here transforms PocketBase from a great BaaS into a first-class TypeScript citizen. When your schema changes, TypeScript will guide you to every place that needs updating, no more runtime surprises or manual grep searches through your codebase.&lt;/p&gt;&lt;p&gt;If you want more on PocketBase, be sure to sign up, follow or even contact me.&lt;/p&gt;&lt;p&gt;It&apos;s my plan to update this blog into a full tutorial and getting-started. Hope to see you around!&lt;/p&gt;&lt;p&gt;Cheers, and, by the way, &quot;BaaS&quot; translates to &quot;boss&quot; in Dutch.&lt;/p&gt;&lt;p&gt;&lt;hr&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Last updated: 2025-11-25&lt;/em&gt;
            &lt;/div&gt;</content>
  </entry>
  <entry>
    <title>Renovate</title>
    <link href="https://blog.nergy.space/blogs/renovate"/>
    <id>https://blog.nergy.space/blogs/renovate</id>
    <published>2025-09-04T00:00:00.000Z</published>
    <updated>2025-09-04T00:00:00.000Z</updated>
    <author><name>Christian / Nergy101</name></author>
    <summary>In a large team, a lot gets built. The question is: will everything that gets built also get proper maintenance? Keeping dependencies up-to-date is one of the highest ROI activities you can automate. This post shows how I use Renovate to keep projects healthy without turning dependency updates into…</summary>
    <content type="html">&lt;div class=&quot;container&quot;&gt;
                &lt;h1 id=&quot;let-s-renovate-your-software-dependencies&quot;&gt;&lt;a href=&quot;#let-s-renovate-your-software-dependencies&quot; class=&quot;header-anchor&quot;&gt;Let&apos;s Renovate your software dependencies&lt;/a&gt;&lt;/h1&gt;&lt;p&gt;In a large team, a lot gets built. The question is: will everything that gets built also get proper maintenance? Keeping dependencies up-to-date is one of the highest ROI activities you can automate. This post shows how I use Renovate to keep projects healthy without turning dependency updates into a full‑time job.&lt;br&gt;&lt;h2 id=&quot;what-is-renovate&quot;&gt;&lt;a href=&quot;#what-is-renovate&quot; class=&quot;header-anchor&quot;&gt;What is Renovate?&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;https://docs.renovatebot.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Renovate&lt;/a&gt; is a bot that scans your repositories, detects outdated dependencies, and creates pull requests with version bumps and changelogs. It supports many ecosystems (npm, NuGet, Docker, GitHub Actions, Terraform, Bicep, etc.) and can be run as a GitHub App, a self-hosted Docker container, or inside CI (e.g., Azure DevOps, GitHub Actions).&lt;/p&gt;&lt;p&gt;Key things I like:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Automated PRs with helpful titles and release notes (when GitHub tokens are configured)&lt;/li&gt;
&lt;li&gt;Smart grouping (e.g., group non‑breaking updates, keep majors separate)&lt;/li&gt;
&lt;li&gt;Auto-merge for safe updates &lt;strong&gt;once checks pass&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Custom schedules so updates arrive when your team can handle them&lt;/li&gt;
&lt;li&gt;Wide ecosystem support across backend, frontend, infra, and pipelines&lt;/li&gt;
&lt;/ul&gt; &lt;h2 id=&quot;how-to-use-renovate&quot;&gt;&lt;a href=&quot;#how-to-use-renovate&quot; class=&quot;header-anchor&quot;&gt;How to use Renovate?&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;There are two common setups I have worked with:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;GitHub: install the official Renovate GitHub App (simplest, lowest friction)&lt;/li&gt;
&lt;li&gt;Azure DevOps: run Renovate in a pipeline on a schedule&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;On how renovate and it&apos;s PR groupings work, its good to start with how Semantic Versioning (SemVer) works.&lt;br&gt;&lt;h3 id=&quot;semantic-versioning&quot;&gt;&lt;a href=&quot;#semantic-versioning&quot; class=&quot;header-anchor&quot;&gt;Semantic Versioning&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;SemVer follows the pattern MAJOR.MINOR.PATCH:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;MAJOR: breaking changes&lt;/li&gt;
&lt;li&gt;MINOR: new features, backwards compatible&lt;/li&gt;
&lt;li&gt;PATCH: bug fixes&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Common version range operators (npm-style) and what they allow:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;^1.2.3&lt;/code&gt; → allow &lt;code&gt;1.x.x&lt;/code&gt; (no major bumps)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;~1.2.3&lt;/code&gt; → allow &lt;code&gt;1.2.x&lt;/code&gt; (patch-only)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;1.2.x&lt;/code&gt; → allow any patch of 1.2&lt;/li&gt;
&lt;li&gt;&lt;code&gt;1.x&lt;/code&gt; → allow any minor/patch of 1&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;NuGet-style ranges (C#) and what they allow:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;[1.2.3]&lt;/code&gt; → exactly &lt;code&gt;1.2.3&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[1.2.3, 2.0.0)&lt;/code&gt; → &lt;code&gt;&gt;= 1.2.3&lt;/code&gt; and &lt;code&gt;&lt; 2.0.0&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;(1.2.3, 2.0.0]&lt;/code&gt; → &lt;code&gt;&gt; 1.2.3&lt;/code&gt; and &lt;code&gt;&lt;= 2.0.0&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;(1.2.3, )&lt;/code&gt; → &lt;code&gt;&gt; 1.2.3&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[1.2.3, )&lt;/code&gt; → &lt;code&gt;&gt;= 1.2.3&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;(, 2.0.0)&lt;/code&gt; → &lt;code&gt;&lt; 2.0.0&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;(, 2.0.0]&lt;/code&gt; → &lt;code&gt;&lt;= 2.0.0&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;1.2.*&lt;/code&gt; → latest &lt;code&gt;1.2.x&lt;/code&gt; (floating patch)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;1.*&lt;/code&gt; → latest &lt;code&gt;1.x&lt;/code&gt; (floating minor)&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Notes:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Pre‑1.0.0 packages can treat MINOR as breaking. Renovate respects this nuance when deciding what is “safe”.&lt;/li&gt;
&lt;li&gt;Lockfiles (e.g., &lt;code&gt;package-lock.json&lt;/code&gt;, &lt;code&gt;pnpm-lock.yaml&lt;/code&gt;) pin exact versions. Renovate updates these lockfiles too, so CI stays reproducible.&lt;/li&gt;
&lt;/ul&gt; &lt;h3 id=&quot;getting-started&quot;&gt;&lt;a href=&quot;#getting-started&quot; class=&quot;header-anchor&quot;&gt;Getting Started&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Create a &lt;code&gt;renovate.json&lt;/code&gt; in the repository root. Here is a battle-tested baseline that mirrors how I like to structure PRs for frontend, backend, and infra:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;json&quot; id=&quot;code-1795777174503-i7hbvtzmm&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;json&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  {
  &amp;quot;$schema&amp;quot;: &amp;quot;https://docs.renovatebot.com/renovate-schema.json&amp;quot;,
  &amp;quot;platform&amp;quot;: &amp;quot;azure&amp;quot;,

  &amp;quot;automerge&amp;quot;: true,
  &amp;quot;automergeType&amp;quot;: &amp;quot;pr&amp;quot;,
  &amp;quot;automergeStrategy&amp;quot;: &amp;quot;merge-commit&amp;quot;,
  &amp;quot;groupName&amp;quot;: &amp;quot;other packages for non-breaking versions&amp;quot;,

  &amp;quot;separateMajorMinor&amp;quot;: false,

  &amp;quot;nuget&amp;quot;: {
    &amp;quot;enabled&amp;quot;: true
  },

  &amp;quot;prHourlyLimit&amp;quot;: 0,

  &amp;quot;ignorePaths&amp;quot;: [&amp;quot;**/node_modules/**&amp;quot;, &amp;quot;**/bower_components/**&amp;quot;],

  &amp;quot;packageRules&amp;quot;: [
    {
      &amp;quot;matchManagers&amp;quot;: [&amp;quot;npm&amp;quot;],
      &amp;quot;groupName&amp;quot;: &amp;quot;npm packages for non-breaking versions&amp;quot;,
      &amp;quot;description&amp;quot;: &amp;quot;npm packages for non-breaking versions&amp;quot;
    },

    {
      &amp;quot;matchManagers&amp;quot;: [&amp;quot;nuget&amp;quot;],
      &amp;quot;groupName&amp;quot;: &amp;quot;nuget packages for non-breaking versions&amp;quot;,
      &amp;quot;description&amp;quot;: &amp;quot;nuget packages for non-breaking versions&amp;quot;
    },

    {
      &amp;quot;matchManagers&amp;quot;: [&amp;quot;npm&amp;quot;],
      &amp;quot;rangeStrategy&amp;quot;: &amp;quot;bump&amp;quot;
    },

    {
      &amp;quot;matchManagers&amp;quot;: [&amp;quot;npm&amp;quot;],
      &amp;quot;matchCurrentValue&amp;quot;: &amp;quot;/^[^^~]/&amp;quot;,
      &amp;quot;groupName&amp;quot;: &amp;quot;Breaking updates npm&amp;quot;,
      &amp;quot;description&amp;quot;: &amp;quot;Consider pinned package updates breaking&amp;quot;
    },

    {
      &amp;quot;matchManagers&amp;quot;: [&amp;quot;npm&amp;quot;],
      &amp;quot;matchCurrentValue&amp;quot;: &amp;quot;/^\\~/&amp;quot;,
      &amp;quot;matchUpdateTypes&amp;quot;: [&amp;quot;minor&amp;quot;],
      &amp;quot;groupName&amp;quot;: &amp;quot;Breaking updates npm&amp;quot;,
      &amp;quot;description&amp;quot;: &amp;quot;Consider minor updates to range versions with a patch range (~) breaking&amp;quot;
    },

    {
      &amp;quot;matchManagers&amp;quot;: [&amp;quot;nuget&amp;quot;],
      &amp;quot;matchCurrentVersion&amp;quot;: &amp;quot;&amp;lt;1.0.0&amp;quot;,
      &amp;quot;groupName&amp;quot;: &amp;quot;Breaking updates nuget&amp;quot;,
      &amp;quot;description&amp;quot;: &amp;quot;Consider updates to packages in beta (version&amp;lt;1.0.0) breaking&amp;quot;
    },

    {
      &amp;quot;matchManagers&amp;quot;: [&amp;quot;nuget&amp;quot;],
      &amp;quot;matchPackageNames&amp;quot;: [&amp;quot;/My\\.Company/&amp;quot;],
      &amp;quot;groupName&amp;quot;: &amp;quot;My.Company package updates nuget&amp;quot;,
      &amp;quot;description&amp;quot;: &amp;quot;My.Company packages&amp;quot;
    },

    {
      &amp;quot;matchManagers&amp;quot;: [&amp;quot;nuget&amp;quot;],
      &amp;quot;matchUpdateTypes&amp;quot;: [&amp;quot;major&amp;quot;],
      &amp;quot;groupName&amp;quot;: &amp;quot;Breaking updates nuget&amp;quot;,
      &amp;quot;description&amp;quot;: &amp;quot;Consider major version updates breaking&amp;quot;
    },

    {
      &amp;quot;matchManagers&amp;quot;: [&amp;quot;npm&amp;quot;],
      &amp;quot;matchUpdateTypes&amp;quot;: [&amp;quot;major&amp;quot;],
      &amp;quot;groupName&amp;quot;: &amp;quot;Breaking updates npm&amp;quot;,
      &amp;quot;description&amp;quot;: &amp;quot;Consider major version updates breaking&amp;quot;
    }
  ]
}

&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;This yields small, predictable PRs for non‑breaking updates (often auto‑merged once checks pass), while majors are isolated for deliberate review.&lt;br&gt;&lt;h3 id=&quot;github&quot;&gt;&lt;a href=&quot;#github&quot; class=&quot;header-anchor&quot;&gt;GitHub&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The easiest path is the official GitHub App.&lt;/p&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;Install the Renovate GitHub App for your org or user.&lt;/li&gt;
&lt;li&gt;Select repositories to enable.&lt;/li&gt;
&lt;li&gt;Add the &lt;code&gt;renovate.json&lt;/code&gt; shown above to your repository.&lt;/li&gt;
&lt;li&gt;Commit and push. The bot will open an onboarding PR; merge it to start.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Tips:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;If you want auto-merge, ensure required status checks exist and are green.&lt;/li&gt;
&lt;li&gt;Use labels/groups to match your team’s ownership model.&lt;/li&gt;
&lt;/ul&gt; &lt;h3 id=&quot;devops&quot;&gt;&lt;a href=&quot;#devops&quot; class=&quot;header-anchor&quot;&gt;DevOps&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;For Azure DevOps, I like to run Renovate via a scheduled pipeline. This uses the built-in &lt;code&gt;System.AccessToken&lt;/code&gt; so you don’t have to manage a personal token. Ensure “Allow scripts to access the OAuth token” is enabled on the pipeline.&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;yaml&quot; id=&quot;code-1795777174503-4mxjcv3mx&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;yaml&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;trigger: none

schedules:
  - cron: &amp;quot;0 3 * * 1&amp;quot; # Every Monday at 03:00
    displayName: Weekday mornings
    always: true
    branches:
      include: [main]

pool:
  vmImage: ubuntu-latest

steps:
  - checkout: self
    persistCredentials: true

  - task: NodeTool@0
    inputs:
      versionSpec: &amp;quot;20.x&amp;quot;

  - script: |
      git config --global user.email &amp;#x27;noreply-bot@example.com&amp;#x27;
      git config --global user.name &amp;#x27;Project Collection Build Service (Org-Project)&amp;#x27;

      npm install -g renovate@latest
      npx --userconfig $(Build.SourcesDirectory)/.npmrc renovate
    env:
      LOG_FILE: &amp;quot;renovate-log&amp;quot;
      TOKEN: $(System.AccessToken)
    workingDirectory: renovate
    displayName: &amp;quot;Run Renovate&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h4 id=&quot;authenticating-to-private-feeds-npm-and-nuget&quot;&gt;&lt;a href=&quot;#authenticating-to-private-feeds-npm-and-nuget&quot; class=&quot;header-anchor&quot;&gt;Authenticating to private feeds (npm and NuGet)&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;For private registries, provide credentials via config files and environment variables.&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Note: In Azure DevOps pipelines, authentication to private feeds can be injected automatically (no tokens/passwords needed in &lt;code&gt;.npmrc&lt;/code&gt;/&lt;code&gt;NuGet.Config&lt;/code&gt;). Ensure the pipeline has access to the feeds and OAuth token access is enabled (or use dedicated authenticate tasks). You must still include the private feed references (registries/scopes/URLs) in these files so tools know where to resolve packages.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;npm: add a root-level &lt;code&gt;.npmrc&lt;/code&gt; and ensure the token env var is available in the pipeline step (the example above passes a token via environment variables).&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;ini&quot; id=&quot;code-1795777174503-vozn4r0un&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;ini&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-ini&quot;&gt;registry=https://registry.npmjs.org/
@my-scope:registry=https://pkgs.example.com/org/_packaging/my-feed/npm/registry/
always-auth=true
//pkgs.example.com/org/_packaging/my-feed/npm/registry/:_authToken=${NPM_TOKEN}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;NuGet: add a root-level &lt;code&gt;NuGet.Config&lt;/code&gt; for restores, and/or configure Renovate &lt;code&gt;hostRules&lt;/code&gt; (as shown below) so Renovate can fetch metadata from private feeds.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;xml&quot; id=&quot;code-1795777174503-hvyh0a46q&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;xml&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-xml&quot;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;
&amp;lt;configuration&amp;gt;
  &amp;lt;packageSources&amp;gt;
    &amp;lt;add key=&amp;quot;nuget.org&amp;quot; value=&amp;quot;https://api.nuget.org/v3/index.json&amp;quot; /&amp;gt;
    &amp;lt;add key=&amp;quot;PrivateFeed&amp;quot; value=&amp;quot;https://pkgs.example.com/ORG/PROJECT/_packaging/FEED/nuget/v3/index.json&amp;quot; /&amp;gt;
  &amp;lt;/packageSources&amp;gt;
  &amp;lt;packageSourceCredentials&amp;gt;
    &amp;lt;PrivateFeed&amp;gt;
      &amp;lt;add key=&amp;quot;Username&amp;quot; value=&amp;quot;token&amp;quot; /&amp;gt;
      &amp;lt;add key=&amp;quot;ClearTextPassword&amp;quot; value=&amp;quot;${NUGET_TOKEN}&amp;quot; /&amp;gt;
    &amp;lt;/PrivateFeed&amp;gt;
  &amp;lt;/packageSourceCredentials&amp;gt;
&amp;lt;/configuration&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Use placeholder values (&lt;code&gt;example.com&lt;/code&gt;, &lt;code&gt;ORG&lt;/code&gt;, &lt;code&gt;PROJECT&lt;/code&gt;, &lt;code&gt;FEED&lt;/code&gt;, &lt;code&gt;@my-scope&lt;/code&gt;) and set &lt;code&gt;NPM&lt;em&gt;TOKEN&lt;/code&gt;/&lt;code&gt;NUGET&lt;/em&gt;TOKEN&lt;/code&gt; securely via your pipeline’s secret variables.&lt;br&gt;&lt;h4 id=&quot;required-config-js-self-hosted&quot;&gt;&lt;a href=&quot;#required-config-js-self-hosted&quot; class=&quot;header-anchor&quot;&gt;Required &lt;code&gt;config.js&lt;/code&gt; (self‑hosted)&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;When running Renovate in CI or Docker (i.e., not via the GitHub App), provide a root‑level &lt;code&gt;config.js&lt;/code&gt; or pass &lt;code&gt;--config-file&lt;/code&gt; to point to it. Minimal example for the Azure DevOps setup above:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;javascript&quot; id=&quot;code-1795777174503-1lgjt3tab&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;javascript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;//* Renovate config for Azure DevOps - Example (generic placeholders)
//* Add config.js for renovate: https://docs.renovatebot.com/modules/platform/azure/#create-a-configjs-file
module.exports = {
  platform: &amp;quot;azure&amp;quot;,
  endpoint: &amp;quot;https://dev.azure.com/your-org/&amp;quot;,
  token: process.env.TOKEN,
  labels: [&amp;quot;renovate&amp;quot;, &amp;quot;dependencies&amp;quot;],
  hostRules: [
    // Azure Artifacts NuGet
    {
      hostType: &amp;quot;nuget&amp;quot;,
      matchHost: &amp;quot;pkgs.dev.azure.com&amp;quot;,
      username: &amp;quot;ignored-for-azure&amp;quot;,
      password: process.env.TOKEN,
    },

    // Azure Artifacts npm
    {
      hostType: &amp;quot;npm&amp;quot;,
      matchHost: &amp;quot;pkgs.dev.azure.com&amp;quot;,
      username: &amp;quot;ignored-for-azure&amp;quot;,
      password: process.env.TOKEN,
    },
  ],
  repositories: [&amp;quot;PROJECT/REPO&amp;quot;], // Azure DevOps: &amp;quot;Project/Repo&amp;quot;
};
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Keep repo‑specific rules in &lt;code&gt;renovate.json&lt;/code&gt; (shown earlier).&lt;/li&gt;
&lt;li&gt;For GitHub, use &lt;code&gt;platform: &apos;github&apos;&lt;/code&gt; and replace &lt;code&gt;token&lt;/code&gt; with &lt;code&gt;token: process.env.GITHUB_TOKEN&lt;/code&gt; based on the env variables.&lt;/li&gt;
&lt;li&gt;For Azure DevOps Server, use &lt;code&gt;platform: &apos;azure&apos;&lt;/code&gt;, and add &lt;code&gt;endpoint&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Notes:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;process.env.Token&lt;/code&gt; comes from &lt;code&gt;$(System.AccessToken)&lt;/code&gt;; make sure the pipeline has permission to access the repo and open PRs.&lt;/li&gt;
&lt;li&gt;If you prefer containers, replace the Bash step with &lt;code&gt;docker run renovate/renovate&lt;/code&gt; and pass the same env vars.&lt;/li&gt;
&lt;/ul&gt; &lt;h2 id=&quot;my-pr-preferences&quot;&gt;&lt;a href=&quot;#my-pr-preferences&quot; class=&quot;header-anchor&quot;&gt;My PR Preferences&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Auto-complete turned on&lt;/li&gt;
&lt;li&gt;Provide a work-item to link if applicable (some teams have a &apos;maintenance&apos; item, or create a new item every sprint)&lt;/li&gt;
&lt;li&gt;Per project; 4 package rules + extra&apos;s&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Backend dependencies non-breaking&lt;/li&gt;
&lt;li&gt;Backend dependencies breaking&lt;/li&gt;
&lt;li&gt;Frontend dependencies non-breaking&lt;/li&gt;
&lt;li&gt;Frontend dependencies breaking&lt;/li&gt;
&lt;li&gt;Extra&apos;s: Bicep/Terraform/Github Actions&lt;/li&gt;
&lt;li&gt;Extra&apos;s: My.Company.\* dependencies&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;&lt;p&gt;How this maps to &lt;code&gt;renovate.json&lt;/code&gt;:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Non‑breaking updates are grouped per ecosystem: &quot;npm packages for non‑breaking versions&quot; and &quot;nuget packages for non‑breaking versions&quot;, and will auto‑merge once checks pass. NPM uses &lt;code&gt;rangeStrategy: &quot;bump&quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Breaking updates are isolated into &quot;Breaking updates npm&quot; and &quot;Breaking updates nuget&quot;. Majors go here by default; pinned NPM deps and &lt;code&gt;~&lt;/code&gt;‑ranged minors are treated as breaking; NuGet pre‑1.0 updates are treated as breaking.&lt;/li&gt;
&lt;li&gt;Internal NuGet packages matching &lt;code&gt;My.Company&lt;/code&gt; get a dedicated group: &quot;My.Company package updates nuget&quot;.&lt;/li&gt;
&lt;li&gt;Global auto‑merge is enabled (&lt;code&gt;automerge: true&lt;/code&gt;) with merge commits (&lt;code&gt;automergeType: &quot;pr&quot;&lt;/code&gt;, &lt;code&gt;automergeStrategy: &quot;merge-commit&quot;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Operational: runs on Azure DevOps (&lt;code&gt;platform: &quot;azure&quot;&lt;/code&gt;), no PR rate limit (&lt;code&gt;prHourlyLimit: 0&lt;/code&gt;), and common folders are ignored (&lt;code&gt;node modules&lt;/code&gt;, &lt;code&gt;bower components&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;In total that should make 4-6 PRs at a time for the configured repository.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Final tips:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Start conservative, then turn on auto‑merge for low-risk groups once you trust the flow.&lt;/li&gt;
&lt;li&gt;Keep CI fast and reliable—Renovate is only as smooth as your test signal.&lt;/li&gt;
&lt;li&gt;Use schedules to avoid a Monday PR flood or weekend noise.&lt;/li&gt;
&lt;/ul&gt;
            &lt;/div&gt;</content>
  </entry>
  <entry>
    <title>Mapperly vs AutoMapper</title>
    <link href="https://blog.nergy.space/blogs/mapperly"/>
    <id>https://blog.nergy.space/blogs/mapperly</id>
    <published>2025-09-01T00:00:00.000Z</published>
    <updated>2025-09-01T00:00:00.000Z</updated>
    <author><name>Christian / Nergy101</name></author>
    <summary>At some point you will map model A to B, C to D, and so on, until you’re thoroughly tired of it. Most .NET developers reach for AutoMapper—a mature, feature-rich library. There’s also Mapperly: a free, open-source alternative that uses Roslyn source generators to emit plain Cmapping code at compile…</summary>
    <content type="html">&lt;div class=&quot;container&quot;&gt;
                &lt;h3 id=&quot;mapperly-better-mappers-and-an-alternative-to-automapper&quot;&gt;&lt;a href=&quot;#mapperly-better-mappers-and-an-alternative-to-automapper&quot; class=&quot;header-anchor&quot;&gt;Mapperly: Better mappers and an alternative to AutoMapper&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;At some point you will map model A to B, C to D, and so on, until you’re thoroughly tired of it. Most .NET developers reach for &lt;strong&gt;AutoMapper&lt;/strong&gt;—a mature, feature-rich library. There’s also &lt;strong&gt;Mapperly&lt;/strong&gt;: a free, open-source alternative that uses Roslyn source generators to emit plain C# mapping code at compile time.&lt;/p&gt;&lt;p&gt;What that buys you:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Performance&lt;/strong&gt;: zero reflection in hot paths; simple IL the JIT can optimize well&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Safety&lt;/strong&gt;: compile-time diagnostics for missing/ambiguous mappings (e.g., RMG020)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DX&lt;/strong&gt;: you can read the generated code when you need insight or a debugger step-through&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;AutoMapper remains excellent, with a huge ecosystem and powerful features. As of v15, AutoMapper requires &lt;a href=&quot;https://automapper.io/#pricing&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;a paid commercial license for larger companies&lt;/a&gt;; see the pricing page for details. Mapperly remains free and open source.&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;https://blog.nergy.space/assets/gifs/Show%20Me%20The%20Money%20GIF.webp&quot; alt=&quot;gif&quot;&gt;&lt;/p&gt;&lt;p&gt;And actually, I fully support Jimmy Bogard for his decision. However it&apos;s also a great opportunity for other libraries to take the stage for anyone that doesn&apos;t want to spend money.&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;models-used-in-this-post&quot;&gt;&lt;a href=&quot;#models-used-in-this-post&quot; class=&quot;header-anchor&quot;&gt;Models used in this post&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;For the examples and benchmarks in this repo, we map a domain &lt;code&gt;Dragon&lt;/code&gt; to a &lt;code&gt;DragonDto&lt;/code&gt; with nested objects and a collection:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;csharp&quot; id=&quot;code-1795777174472-hyvwf5krp&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;csharp&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;public sealed class Dragon
{
    public string Name { get; set; } = string.Empty;
    public string Color { get; set; } = string.Empty;
    public int AgeYears { get; set; }
    public double SizeMeters { get; set; }
    public Rider? Rider { get; set; }
    public Lair? Lair { get; set; }
    public List&amp;lt;Treasure&amp;gt; Hoard { get; set; } = new();
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;csharp&quot; id=&quot;code-1795777174472-l8c9rul4l&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;csharp&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;public sealed class DragonDto
{
    public string DisplayName { get; set; } = string.Empty;
    public string PrimaryColor { get; set; } = string.Empty;
    public string Age { get; set; } = string.Empty;
    public int LengthCentimeters { get; set; }
    public bool IsAncient { get; set; }
    public RiderDto? Pilot { get; set; }
    public LairDto? Hideout { get; set; }
    public List&amp;lt;TreasureDto&amp;gt; HoardItems { get; set; } = new();
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;code-comparison-automapper-vs-mapperly&quot;&gt;&lt;a href=&quot;#code-comparison-automapper-vs-mapperly&quot; class=&quot;header-anchor&quot;&gt;Code comparison: AutoMapper vs Mapperly&lt;/a&gt;&lt;/h2&gt; &lt;h3 id=&quot;automapper-configuration&quot;&gt;&lt;a href=&quot;#automapper-configuration&quot; class=&quot;header-anchor&quot;&gt;AutoMapper configuration&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;csharp&quot; id=&quot;code-1795777174472-up9hkq2r4&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;csharp&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;public sealed class DragonsProfile : Profile
{
    public DragonsProfile()
    {
        CreateMap&amp;lt;Treasure, TreasureDto&amp;gt;()
            .ForMember(d =&amp;gt; d.ItemName, o =&amp;gt; o.MapFrom(s =&amp;gt; s.Name))
            .ForMember(d =&amp;gt; d.Category, o =&amp;gt; o.MapFrom(s =&amp;gt; s.Type.ToString()))
            .ForMember(d =&amp;gt; d.ValueUsd, o =&amp;gt; o.MapFrom(s =&amp;gt; (double)s.EstimatedValue))
            .ForMember(d =&amp;gt; d.WeightGrams, o =&amp;gt; o.MapFrom(s =&amp;gt; (int)System.Math.Round(s.WeightKg * 1000)));

        CreateMap&amp;lt;Lair, LairDto&amp;gt;()
            .ForMember(d =&amp;gt; d.LairName, o =&amp;gt; o.MapFrom(s =&amp;gt; s.Name))
            .ForMember(d =&amp;gt; d.Region, o =&amp;gt; o.MapFrom(s =&amp;gt; s.Location))
            .ForMember(d =&amp;gt; d.Capacity, o =&amp;gt; o.MapFrom(s =&amp;gt; (long)s.Capacity))
            .ForMember(d =&amp;gt; d.Hidden, o =&amp;gt; o.MapFrom(s =&amp;gt; s.IsHidden));

        CreateMap&amp;lt;Rider, RiderDto&amp;gt;()
            .ForMember(d =&amp;gt; d.FullName, o =&amp;gt; o.MapFrom(s =&amp;gt; s.FirstName + &amp;quot; &amp;quot; + s.LastName))
            .ForMember(d =&amp;gt; d.Experience, o =&amp;gt; o.MapFrom(s =&amp;gt; s.ExperienceLevel &amp;lt;= 3 ? &amp;quot;Novice&amp;quot; : (s.ExperienceLevel &amp;lt;= 6 ? &amp;quot;Skilled&amp;quot; : &amp;quot;Expert&amp;quot;)))
            .ForMember(d =&amp;gt; d.City, o =&amp;gt; o.MapFrom(s =&amp;gt; s.HomeTown));

        CreateMap&amp;lt;Dragon, DragonDto&amp;gt;()
            .ForMember(d =&amp;gt; d.DisplayName, o =&amp;gt; o.MapFrom(s =&amp;gt; s.Name))
            .ForMember(d =&amp;gt; d.PrimaryColor, o =&amp;gt; o.MapFrom(s =&amp;gt; s.Color))
            .ForMember(d =&amp;gt; d.Age, o =&amp;gt; o.MapFrom(s =&amp;gt; s.AgeYears.ToString()))
            .ForMember(d =&amp;gt; d.IsAncient, o =&amp;gt; o.MapFrom(s =&amp;gt; s.AgeYears &amp;gt;= 1000))
            .ForMember(d =&amp;gt; d.LengthCentimeters, o =&amp;gt; o.MapFrom(s =&amp;gt; (int)System.Math.Round(s.SizeMeters * 100)))
            .ForMember(d =&amp;gt; d.Pilot, o =&amp;gt; o.MapFrom(s =&amp;gt; s.Rider))
            .ForMember(d =&amp;gt; d.Hideout, o =&amp;gt; o.MapFrom(s =&amp;gt; s.Lair))
            .ForMember(d =&amp;gt; d.HoardItems, o =&amp;gt; o.MapFrom(s =&amp;gt; s.Hoard));
    }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h3 id=&quot;mapperly-mapper-with-source-generation&quot;&gt;&lt;a href=&quot;#mapperly-mapper-with-source-generation&quot; class=&quot;header-anchor&quot;&gt;Mapperly mapper with source generation&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;csharp&quot; id=&quot;code-1795777174472-tuy3zga1p&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;csharp&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;[Mapper]
public partial class DragonsMapper
{
    [MapProperty(nameof(Dragon.Name), nameof(DragonDto.DisplayName))]
    [MapProperty(nameof(Dragon.Color), nameof(DragonDto.PrimaryColor))]
    [MapProperty(nameof(Dragon.AgeYears), nameof(DragonDto.Age))]
    [MapProperty(nameof(Dragon.AgeYears), nameof(DragonDto.IsAncient))]
    [MapProperty(nameof(Dragon.SizeMeters), nameof(DragonDto.LengthCentimeters))]
    [MapProperty(nameof(Dragon.Rider), nameof(DragonDto.Pilot))]
    [MapProperty(nameof(Dragon.Lair), nameof(DragonDto.Hideout))]
    [MapProperty(nameof(Dragon.Hoard), nameof(DragonDto.HoardItems))]
    public partial DragonDto MapDragon(Dragon source);

    public partial List&amp;lt;DragonDto&amp;gt; MapDragons(List&amp;lt;Dragon&amp;gt; source);

    // Custom helpers re-used by the generated mapper
    [UserMapping]
    private static RiderDto MapRider(Rider source) =&amp;gt; new()
    {
        FullName = string.Concat(source.FirstName, &amp;quot; &amp;quot;, source.LastName),
        Experience = MapExperience(source.ExperienceLevel),
        City = source.HomeTown
    };

    [UserMapping]
    private static LairDto MapLair(Lair source) =&amp;gt; new()
    {
        LairName = source.Name,
        Region = source.Location,
        Capacity = source.Capacity,
        Hidden = source.IsHidden
    };

    [MapProperty(nameof(Treasure.Name), nameof(TreasureDto.ItemName))]
    [MapProperty(nameof(Treasure.Type), nameof(TreasureDto.Category))]
    [MapProperty(nameof(Treasure.EstimatedValue), nameof(TreasureDto.ValueUsd))]
    [MapProperty(nameof(Treasure.WeightKg), nameof(TreasureDto.WeightGrams))]
    public partial TreasureDto MapTreasure(Treasure source);

    [UserMapping]
    private static string MapExperience(int level) =&amp;gt; level switch
    {
        &amp;lt;= 3 =&amp;gt; &amp;quot;Novice&amp;quot;,
        &amp;lt;= 6 =&amp;gt; &amp;quot;Skilled&amp;quot;,
        _ =&amp;gt; &amp;quot;Expert&amp;quot;
    };
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;With Mapperly you keep concise, intention-revealing declarations and let the generator produce the concrete mapping code. You can also open the generated C# to review exactly what runs.&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;https://blog.nergy.space/assets/gifs/James%20Franco%20GIF.webp&quot; alt=&quot;gif&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;benchmarks-throughput-and-allocations&quot;&gt;&lt;a href=&quot;#benchmarks-throughput-and-allocations&quot; class=&quot;header-anchor&quot;&gt;Benchmarks: throughput and allocations&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;I used BenchmarkDotNet to compare both approaches on a Mac M2, .NET 9, mapping single items and collections of 1k, 10k, 100k, and 1M dragons.&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Single item&lt;/strong&gt;: AutoMapper was ~1.37–1.84× slower than Mapperly and allocated ~1.16× more. Average was about 1.45× slower.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Collections&lt;/strong&gt;: AutoMapper was ~1.10–1.37× slower and allocated ~1.18× more&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;div class=&quot;table-responsive&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Method&lt;/th&gt;&lt;th&gt;Entities&lt;/th&gt;&lt;th&gt;Time Ratio&lt;/th&gt;&lt;th&gt;Alloc Ratio&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Mapperly Collection&lt;/td&gt;&lt;td&gt;1.000&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;AutoMapper Collection&lt;/td&gt;&lt;td&gt;1.000&lt;/td&gt;&lt;td&gt;1.14&lt;/td&gt;&lt;td&gt;1.17&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Mapperly Collection&lt;/td&gt;&lt;td&gt;10.000&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;AutoMapper Collection&lt;/td&gt;&lt;td&gt;10.000&lt;/td&gt;&lt;td&gt;1.37&lt;/td&gt;&lt;td&gt;1.18&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Mapperly Collection&lt;/td&gt;&lt;td&gt;100.000&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;AutoMapper Collection&lt;/td&gt;&lt;td&gt;100.000&lt;/td&gt;&lt;td&gt;1.10&lt;/td&gt;&lt;td&gt;1.18&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Mapperly Collection&lt;/td&gt;&lt;td&gt;1.000.000&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;AutoMapper Collection&lt;/td&gt;&lt;td&gt;1.000.000&lt;/td&gt;&lt;td&gt;1.26&lt;/td&gt;&lt;td&gt;1.17&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Mapperly Single&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;AutoMapper Single&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1.45&lt;/td&gt;&lt;td&gt;1.16&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;hr&gt; &lt;h2 id=&quot;advanced-and-nested-mapping&quot;&gt;&lt;a href=&quot;#advanced-and-nested-mapping&quot; class=&quot;header-anchor&quot;&gt;Advanced and nested mapping&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The sample shows nested mapping for &lt;code&gt;Rider&lt;/code&gt; and &lt;code&gt;Lair&lt;/code&gt;, and a collection of &lt;code&gt;Treasure&lt;/code&gt;. Mapperly lets you:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Flatten/unflatten&lt;/strong&gt; via &lt;code&gt;[MapProperty]&lt;/code&gt; between different shapes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compose&lt;/strong&gt; generated code with your own &lt;code&gt;[UserMapping]&lt;/code&gt; helpers&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Get diagnostics&lt;/strong&gt; when you forget a property (e.g., missing &lt;code&gt;MapProperty&lt;/code&gt;), early at compile time&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;You could, for example, convert units (&lt;code&gt;SizeMeters&lt;/code&gt; → &lt;code&gt;LengthCentimeters&lt;/code&gt;), compute flags (&lt;code&gt;IsAncient&lt;/code&gt;), and merge names (&lt;code&gt;FullName&lt;/code&gt;) — all with small helpers that remain easy to test.&lt;br&gt;&lt;h2 id=&quot;compile-time-diagnostics&quot;&gt;&lt;a href=&quot;#compile-time-diagnostics&quot; class=&quot;header-anchor&quot;&gt;Compile-time diagnostics&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If we were to add a &lt;code&gt;CreatedAt&lt;/code&gt; datetime field to the dragon like so:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;csharp&quot; id=&quot;code-1795777174472-3r248alfg&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;csharp&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;public sealed class Dragon
{
    public string Name { get; set; } = string.Empty;
    public string Color { get; set; } = string.Empty;
    public int AgeYears { get; set; }
    public double SizeMeters { get; set; }
    public Rider? Rider { get; set; }
    public Lair? Lair { get; set; }
    public List&amp;lt;Treasure&amp;gt; Hoard { get; set; } = new();

    public DateTime CreatedAt { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;our compiler will tell us:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;log&quot; id=&quot;code-1795777174472-sn23u6vdl&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;log&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-log&quot;&gt;The member CreatedAt on the mapping source type
Benchmarks.Models.DomainModels.Dragon
is not mapped to any member on the mapping
target type Benchmarks.Models.DtoModels.DragonDto
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;And that&apos;s great, because it allows us to &lt;strong&gt;know for sure&lt;/strong&gt; we didn&apos;t miss any properties to map,&lt;br&gt;and we have &lt;em&gt;at least&lt;/em&gt; specified what to do with every property.&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;when-to-choose-which&quot;&gt;&lt;a href=&quot;#when-to-choose-which&quot; class=&quot;header-anchor&quot;&gt;When to choose which&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mapperly&lt;/strong&gt;: prefer for performance-sensitive or large-batch mappings; when you want readable generated code and compile-time feedback. Also the licence is more permissive and its fully free to use, even for large companies.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AutoMapper&lt;/strong&gt;: prefer when you need advanced projection features (EF/Linq etc.), a broad ecosystem, or you already have significant profiles configured.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;As ever, benchmark with your own models and sizes.&lt;/p&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;resources&quot;&gt;&lt;a href=&quot;#resources&quot; class=&quot;header-anchor&quot;&gt;Resources&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Mapperly GitHub: &lt;code&gt;https://github.com/riok/mapperly&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Mapperly documentation: &lt;code&gt;https://mapperly.riok.app/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;AutoMapper website &amp; pricing: &lt;code&gt;https://automapper.io/#pricing&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;BenchmarkDotNet: &lt;code&gt;https://benchmarkdotnet.org/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt; &lt;h2 id=&quot;conclusion&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;header-anchor&quot;&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Mapperly’s source-generated approach delivers simple, fast mapping code and early diagnostics.&lt;/p&gt;&lt;p&gt;In short:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;https://blog.nergy.space/assets/gifs/Joe%20Biden%20GIF%20by%20GIPHY%20News.webp&quot; alt=&quot;gif&quot;&gt;&lt;/p&gt;&lt;p&gt;So go give it a try, and I am sure you won&apos;t regret it!&lt;/p&gt;&lt;p&gt;&lt;hr&gt;&lt;/p&gt;&lt;p&gt;Want to stay updated? Bookmark this page or follow me on &lt;a href=&quot;https://github.com/Nergy101&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;GitHub&lt;/a&gt;
            &lt;/div&gt;</content>
  </entry>
  <entry>
    <title>Retro Ranker</title>
    <link href="https://blog.nergy.space/blogs/retro-ranker"/>
    <id>https://blog.nergy.space/blogs/retro-ranker</id>
    <published>2025-04-03T00:00:00.000Z</published>
    <updated>2025-04-03T00:00:00.000Z</updated>
    <author><name>Christian / Nergy101</name></author>
    <summary>When I started building Retro Ranker — a platform for ranking and comparing retro gaming devices — I wanted a fast, modern, and SEO-friendly web framework. After evaluating several options, I chose Deno Fresh, and this post dives into my experience with it.</summary>
    <content type="html">&lt;div class=&quot;container&quot;&gt;
                &lt;h1 id=&quot;building-retro-ranker-with-deno-fresh-a-developer-s-journey&quot;&gt;&lt;a href=&quot;#building-retro-ranker-with-deno-fresh-a-developer-s-journey&quot; class=&quot;header-anchor&quot;&gt;Building Retro Ranker with Deno Fresh: A Developer&apos;s Journey&lt;/a&gt;&lt;/h1&gt;&lt;p&gt;When I started building &lt;a href=&quot;https://retroranker.site&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Retro Ranker&lt;/a&gt; — a platform for ranking and comparing retro gaming devices — I wanted a fast, modern, and SEO-friendly web framework. After evaluating several options, I chose Deno Fresh, and this post dives into my experience with it.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Some screenshots contain paths within the GitHub repo.&lt;br&gt;&lt;h2 id=&quot;introduction&quot;&gt;&lt;a href=&quot;#introduction&quot; class=&quot;header-anchor&quot;&gt;Introduction&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The decision to use Deno Fresh was driven by several key factors. First and foremost, I wanted a framework that would allow me to build a fast, SEO-friendly website without the complexity of traditional server-side rendering solutions. Deno Fresh&apos;s zero-configuration approach and built-in TypeScript support made it an attractive choice.&lt;/p&gt;&lt;p&gt;The framework&apos;s &quot;islands architecture&quot; was particularly appealing for my use case. Retro Ranker needed to be interactive while maintaining excellent performance, and Fresh&apos;s approach of only hydrating the parts of the page that need interactivity (islands) while keeping the rest static was perfect for this balance.&lt;br&gt;&lt;h2 id=&quot;key-benefits-of-using-deno-fresh&quot;&gt;&lt;a href=&quot;#key-benefits-of-using-deno-fresh&quot; class=&quot;header-anchor&quot;&gt;Key Benefits of Using Deno Fresh&lt;/a&gt;&lt;/h2&gt; &lt;h3 id=&quot;developer-experience&quot;&gt;&lt;a href=&quot;#developer-experience&quot; class=&quot;header-anchor&quot;&gt;Developer Experience&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The developer experience with Deno Fresh was outstanding. The framework&apos;s file-based routing system made it incredibly intuitive to organize my application. Creating new routes was as simple as adding files to the &lt;code&gt;routes&lt;/code&gt; directory.&lt;br&gt;&lt;h3 id=&quot;islands-architecture&quot;&gt;&lt;a href=&quot;#islands-architecture&quot; class=&quot;header-anchor&quot;&gt;Islands Architecture&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The &apos;islands&apos; architecture was a game-changer for performance optimization. I could keep most of my pages static while adding interactivity only where needed. For example, the device comparison feature uses islands for interactive charts and filtering.&lt;/p&gt;&lt;p&gt;Besides islands, there&apos;s also &apos;normal&apos; server-side rendered components. This leads to a pattern where data is retrieved server-side and passed to:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Page &apos;static&apos; components&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Server-side &apos;static&apos; components&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Client-side island &apos;interactive&apos; components&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Which is quite a different world when you&apos;re used to writing fully client-side applications with the likes of React, Angular, and Vue.&lt;br&gt;&lt;h3 id=&quot;built-in-typescript-support&quot;&gt;&lt;a href=&quot;#built-in-typescript-support&quot; class=&quot;header-anchor&quot;&gt;Built-in TypeScript Support&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Having TypeScript support out of the box was invaluable. The type safety helped catch potential issues early in development, and the excellent IDE integration made refactoring a breeze. This came in handy not just within the code itself, but also for the local developer experience and CI/CD, which uses Deno to run separate typescript-scripts. Think of:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Fetching device information from the community data source&lt;/li&gt;
&lt;li&gt;Scraping the required device images&lt;/li&gt;
&lt;li&gt;Saving all data to a local json file (&apos;cache&apos;) and PocketBase&lt;/li&gt;
&lt;/ul&gt; &lt;h3 id=&quot;performance&quot;&gt;&lt;a href=&quot;#performance&quot; class=&quot;header-anchor&quot;&gt;Performance&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The performance benefits were immediately noticeable. Pages loaded quickly, and the partial hydration model meant that interactive elements didn&apos;t slow down the entire page. This was particularly important for Retro Ranker, which features complex device comparison charts and filtering systems.&lt;br&gt;&lt;h2 id=&quot;common-challenges-and-how-i-solved-them&quot;&gt;&lt;a href=&quot;#common-challenges-and-how-i-solved-them&quot; class=&quot;header-anchor&quot;&gt;Common Challenges (and How I Solved Them)&lt;/a&gt;&lt;/h2&gt; &lt;h3 id=&quot;third-party-library-integration&quot;&gt;&lt;a href=&quot;#third-party-library-integration&quot; class=&quot;header-anchor&quot;&gt;Third-Party Library Integration&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;One of the main challenges was integrating third-party libraries. While Deno&apos;s import system is powerful, some npm packages require additional configuration. I solved this by using the &lt;code&gt;deno.json&lt;/code&gt; configuration file to map imports from different sources like &lt;code&gt;deno.land&lt;/code&gt;, &lt;code&gt;esm.sh&lt;/code&gt;, &lt;code&gt;jsr&lt;/code&gt; and &lt;code&gt;npm&lt;/code&gt;:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;json&quot; id=&quot;code-1795777174507-2wvexg65e&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;json&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &amp;quot;imports&amp;quot;: {
    &amp;quot;preact&amp;quot;: &amp;quot;https://esm.sh/preact@10.19.6&amp;quot;,
    &amp;quot;preact/&amp;quot;: &amp;quot;https://esm.sh/preact@10.19.6/&amp;quot;,
    &amp;quot;preact-render-to-string&amp;quot;: &amp;quot;https://esm.sh/*preact-render-to-string&amp;quot;,
    &amp;quot;@preact/signals&amp;quot;: &amp;quot;https://esm.sh/*@preact/signals&amp;quot;,
    &amp;quot;@preact/signals-core&amp;quot;: &amp;quot;https://esm.sh/*@preact/signals-core&amp;quot;
  }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h3 id=&quot;state-management&quot;&gt;&lt;a href=&quot;#state-management&quot; class=&quot;header-anchor&quot;&gt;State Management&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Managing state across islands required careful consideration. I ended up using Preact Signals for reactive state management, which worked well with Fresh&apos;s architecture:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174507-01lyfcrhs&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { signal } from &amp;quot;@preact/signals&amp;quot;;

// Global state management
export const selectedDevices = signal&amp;lt;Device[]&amp;gt;([]);
export const comparisonMode = signal&amp;lt;&amp;quot;chart&amp;quot; | &amp;quot;table&amp;quot;&amp;gt;(&amp;quot;chart&amp;quot;);
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h3 id=&quot;deployment&quot;&gt;&lt;a href=&quot;#deployment&quot; class=&quot;header-anchor&quot;&gt;Deployment&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Deploying to production was initially challenging, but the Fresh team&apos;s documentation and the Deno Deploy platform made it straightforward. I used a Dockerfile for containerization:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;dockerfile&quot; id=&quot;code-1795777174507-quj6k056m&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;dockerfile&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-dockerfile&quot;&gt;FROM denoland/deno:1.40

WORKDIR /app
COPY . .

RUN deno cache main.ts

EXPOSE 8000

CMD [&amp;quot;deno&amp;quot;, &amp;quot;run&amp;quot;, &amp;quot;--allow-net&amp;quot;, &amp;quot;--allow-read&amp;quot;, &amp;quot;--allow-env&amp;quot;, &amp;quot;main.ts&amp;quot;]
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h3 id=&quot;integrating-pocketbase&quot;&gt;&lt;a href=&quot;#integrating-pocketbase&quot; class=&quot;header-anchor&quot;&gt;Integrating PocketBase&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The integration was implemented through a custom &lt;code&gt;PocketBaseService&lt;/code&gt; that handles all interactions with the Pocketbase instance. What makes this setup particularly elegant is how it leverages Deno&apos;s native TypeScript support and Fresh&apos;s server-side capabilities.&lt;/p&gt;&lt;p&gt;The service provides a three-tier authentication model using &lt;code&gt;PocketBaseService&lt;/code&gt;, which handles all data access:&lt;/p&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Public access&lt;/strong&gt; – for read-only operations (like device browsing)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Authenticated users&lt;/strong&gt; – for personal collections, likes, saves, and comments&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Superuser access&lt;/strong&gt; – for admin-level tasks like analytics, bulk queries, and cross-user queries&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;This approach works despite PocketBase not being designed for server-side use. With Deno&apos;s native TypeScript and cookie handling, I made it secure and functional, even if not the cleanest solution.&lt;br&gt;&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;header-anchor&quot;&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Would I use Deno Fresh again? &lt;strong&gt;Absolutely.&lt;/strong&gt; For content-heavy projects that need high performance and great DX, it&apos;s hard to beat.&lt;/p&gt;&lt;p&gt;It&apos;s particularly well-suited for:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;✅ Content-heavy websites that need SEO optimization&lt;/li&gt;
&lt;li&gt;✅ Applications requiring partial interactivity&lt;/li&gt;
&lt;li&gt;✅ Projects where TypeScript is a priority&lt;/li&gt;
&lt;li&gt;✅ Developers who value simplicity and convention over configuration&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;🕹️ &lt;strong&gt;If you&apos;re building a modern, SEO-optimized site with partial interactivity — and love working with TypeScript — give Deno Fresh a shot.&lt;/strong&gt;
            &lt;/div&gt;</content>
  </entry>
  <entry>
    <title>Fluent Results</title>
    <link href="https://blog.nergy.space/blogs/fluent-results"/>
    <id>https://blog.nergy.space/blogs/fluent-results</id>
    <published>2025-01-09T00:00:00.000Z</published>
    <updated>2025-01-09T00:00:00.000Z</updated>
    <author><name>Christian / Nergy101</name></author>
    <summary>As a programmer, you&apos;ve surely thrown an exception/error or two. For this blog, I will call them exceptions. Throwing exceptions is perfectly normal, and it is often encouraged to &quot;Fail fast!&quot;. For the longest time, I agreed. While writing APIs I would throw exceptions, catch them through some…</summary>
    <content type="html">&lt;div class=&quot;container&quot;&gt;
                &lt;h1 id=&quot;fluent-results-a-better-approach-to-error-handling&quot;&gt;&lt;a href=&quot;#fluent-results-a-better-approach-to-error-handling&quot; class=&quot;header-anchor&quot;&gt;Fluent Results: A Better Approach to Error Handling&lt;/a&gt;&lt;/h1&gt;&lt;p&gt;As a programmer, you&apos;ve surely thrown an exception/error or two. For this blog, I will call them exceptions. Throwing exceptions is perfectly normal, and it is often encouraged to &quot;Fail fast!&quot;. For the longest time, I agreed. While writing APIs I would throw exceptions, catch them through some middleware, and return with proper response codes or details. However, sometimes I would miss some information, not &quot;know&quot; the details of that specific exception anymore, or the location where the exception occurred would be hard to trace back.&lt;br&gt;&lt;h2 id=&quot;table-of-contents&quot;&gt;&lt;a href=&quot;#table-of-contents&quot; class=&quot;header-anchor&quot;&gt;Table of Contents&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#fluent-results-a-better-approach-to-error-handling&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Fluent Results: A Better Approach to Error Handling&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#table-of-contents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Table of Contents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#the-rust-inspiration&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;The Rust Inspiration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#rfc-7807---problem-details-for-http-apis&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;RFC 7807 - Problem Details for HTTP APIs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#enter-fluentresults&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Enter FluentResults&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#exception-mapping&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Exception Mapping&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#conclusion&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;the-rust-inspiration&quot;&gt;&lt;a href=&quot;#the-rust-inspiration&quot; class=&quot;header-anchor&quot;&gt;The Rust Inspiration&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;However, while I was fiddling with Rust, I was intrigued by their Result-based approach. The Result-based approach preaches that...
&lt;blockquote&gt;&lt;strong&gt;Everything&lt;/strong&gt; is a Result&lt;/blockquote&gt; &quot;So that means if I encounter an exceptional case in my code... I don&apos;t throw?&quot;&lt;/p&gt;&lt;p&gt;Yep, that&apos;s exactly what it means. Instead, we will return some kind of problem detail describing the exceptional case, or anything else we want to send back. At my own work, we prefer to return a &quot;ProblemDetail&quot;:&lt;br&gt;&lt;h2 id=&quot;rfc-7807-problem-details-for-http-apis&quot;&gt;&lt;a href=&quot;#rfc-7807-problem-details-for-http-apis&quot; class=&quot;header-anchor&quot;&gt;RFC 7807 - Problem Details for HTTP APIs&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;An example of this RFC in JSON:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;json&quot; id=&quot;code-1795777174539-uvbrizi5n&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;json&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &amp;quot;type&amp;quot;: &amp;quot;https://example.com/probs/out-of-credit&amp;quot;,
  &amp;quot;title&amp;quot;: &amp;quot;You do not have enough credit.&amp;quot;,
  &amp;quot;detail&amp;quot;: &amp;quot;Your current balance is 30, but that costs 50.&amp;quot;,
  &amp;quot;instance&amp;quot;: &amp;quot;/account/12345/msgs/abc&amp;quot;,
  &amp;quot;balance&amp;quot;: 30,
  &amp;quot;accounts&amp;quot;: [&amp;quot;/account/12345&amp;quot;, &amp;quot;/account/67890&amp;quot;]
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;As you can see, if I were to return details like this, it would be a lot more descriptive than just seeing that I had a &quot;NotEnoughCreditException&quot; at some point. For development purposes only, we usually also include the full exception and stack trace. For security purposes, though, we don&apos;t do this on acceptance or production.&lt;br&gt;&lt;h2 id=&quot;enter-fluentresults&quot;&gt;&lt;a href=&quot;#enter-fluentresults&quot; class=&quot;header-anchor&quot;&gt;Enter FluentResults&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;For anything C#, I&apos;m a big fan of the &quot;Fluent...&quot; packages like FluentValidations, FluentAssertions, etc. So when I saw there&apos;s also a FluentResults package, I got very stoked.&lt;/p&gt;&lt;p&gt;Let&apos;s see what it looks like!&lt;/p&gt;&lt;p&gt;In its basis, a Result is an object indicating Success (Ok) or Failure (Fail):&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;csharp&quot; id=&quot;code-1795777174539-qv0j1unls&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;csharp&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;// Success case
Result result = Result.Ok();

// Failure case
Result result = Result.Fail(&amp;quot;Something went wrong&amp;quot;);
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Of course, we can return these results &quot;manually&quot; from our methods, but we can also &quot;map&quot; certain kinds of exceptions to certain result errors, using the Setup and Try methods. Let&apos;s try our critical method (pun intended):&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;csharp&quot; id=&quot;code-1795777174539-js0vwwodb&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;csharp&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;// Manual approach
public Result DoSomethingCritical()
{
    try
    {
        // Critical operation
        return Result.Ok();
    }
    catch (Exception ex)
    {
        return Result.Fail(ex.Message);
    }
}

// Using FluentResults Try method
public Result DoSomethingCritical()
{
    return Result.Try(() =&amp;gt; {
        // Critical operation
    });
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;
&lt;blockquote&gt;&lt;strong&gt;Note:&lt;/strong&gt; All of FluentResults works sync and async&lt;/blockquote&gt;&lt;h2 id=&quot;exception-mapping&quot;&gt;&lt;a href=&quot;#exception-mapping&quot; class=&quot;header-anchor&quot;&gt;Exception Mapping&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let&apos;s say, the critical exception is of type &lt;code&gt;DomainException&lt;/code&gt;. If we have configured FluentResults with the Setup as seen below:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;csharp&quot; id=&quot;code-1795777174539-3sskejodi&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;csharp&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;Result.Setup(options =&amp;gt;
{
    options.ErrorFactory = exception =&amp;gt;
    {
        if (exception is DomainException domainEx)
        {
            return new DomainExceptionError(domainEx.Message);
        }
        return new Error(exception.Message);
    };
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;We can make FluentResults return an Error in its result instead:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;csharp&quot; id=&quot;code-1795777174539-y7rgu2vj0&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;csharp&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;// Error is from the FluentResults package
public class DomainExceptionError : Error
{
    public DomainExceptionError(string message) : base(message)
    {
    }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;This &lt;code&gt;DomainExceptionError&lt;/code&gt; will now be in the &lt;code&gt;result.Errors&lt;/code&gt; array. Using these same mechanics, we could create a descriptive ProblemDetail that inherits from the Error class, and presto.&lt;br&gt;&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;header-anchor&quot;&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;I&apos;m not quite done with this Blog, but it&apos;s good enough to publish.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Stay tuned!&lt;/strong&gt;
            &lt;/div&gt;</content>
  </entry>
  <entry>
    <title>Playwright Testing</title>
    <link href="https://blog.nergy.space/blogs/playwright-testing"/>
    <id>https://blog.nergy.space/blogs/playwright-testing</id>
    <published>2024-12-21T00:00:00.000Z</published>
    <updated>2024-12-21T00:00:00.000Z</updated>
    <author><name>Christian / Nergy101</name></author>
    <summary>Testing web applications can be a daunting task, especially when you need to ensure your app works across different browsers, devices, and user interactions. Manual testing becomes unsustainable as your application grows, and that&apos;s where Playwright comes in as a powerful end-to-end testing…</summary>
    <content type="html">&lt;div class=&quot;container&quot;&gt;
                &lt;h1 id=&quot;playwright-testing-for-retro-ranker&quot;&gt;&lt;a href=&quot;#playwright-testing-for-retro-ranker&quot; class=&quot;header-anchor&quot;&gt;Playwright Testing for Retro Ranker&lt;/a&gt;&lt;/h1&gt;&lt;p&gt;Testing web applications can be a daunting task, especially when you need to ensure your app works across different browsers, devices, and user interactions. Manual testing becomes unsustainable as your application grows, and that&apos;s where &lt;a href=&quot;https://playwright.dev&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Playwright&lt;/a&gt; comes in as a powerful end-to-end testing solution.&lt;/p&gt;&lt;p&gt;In this post, I&apos;ll walk through how I set up a comprehensive Playwright testing suite for &lt;a href=&quot;https://retroranker.site&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Retro Ranker&lt;/a&gt;, a Fresh/Deno-based web application for comparing retro gaming handhelds. This setup includes multi-browser testing, CI/CD integration, helper utilities, and robust test patterns.&lt;br&gt;&lt;h2 id=&quot;table-of-contents&quot;&gt;&lt;a href=&quot;#table-of-contents&quot; class=&quot;header-anchor&quot;&gt;Table of Contents&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#playwright-testing-for-retro-ranker&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Playwright Testing for Retro Ranker&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#table-of-contents&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Table of Contents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#introduction&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#project-structure&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Project Structure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#configuration-setup&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Configuration Setup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#test-helper-architecture&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Test Helper Architecture&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#testhelpers-class&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;TestHelpers Class&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#authhelpers-class&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;AuthHelpers Class&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#constants-management&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Constants Management&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;a href=&quot;#writing-effective-tests&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Writing Effective Tests&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#home-page-tests&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Home Page Tests&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#authentication-tests&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Authentication Tests&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#using-helper-functions&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Using Helper Functions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;a href=&quot;#cicd-integration&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;CI/CD Integration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#best-practices-and-patterns&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Best Practices and Patterns&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#1-environment-configuration&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;1. Environment Configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#2-robust-waiting-strategies&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;2. Robust Waiting Strategies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#3-test-data-management&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;3. Test Data Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#4-error-handling-and-recovery&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;4. Error Handling and Recovery&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#5-responsive-testing&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;5. Responsive Testing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;a href=&quot;#conclusion&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;&lt;p&gt;&lt;hr&gt; &lt;h2 id=&quot;introduction&quot;&gt;&lt;a href=&quot;#introduction&quot; class=&quot;header-anchor&quot;&gt;Introduction&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Playwright is a modern end-to-end testing framework that supports multiple browsers (Chromium, Firefox, Safari) and provides excellent developer experience. For Retro Ranker, I needed a testing solution that could:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Test across multiple browsers and devices&lt;/li&gt;
&lt;li&gt;Handle authentication flows&lt;/li&gt;
&lt;li&gt;Test responsive design&lt;/li&gt;
&lt;li&gt;Integrate with my Fresh/Deno stack&lt;/li&gt;
&lt;li&gt;Provide reliable CI/CD feedback&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Let&apos;s dive into how I achieved this.&lt;br&gt;&lt;h2 id=&quot;project-structure&quot;&gt;&lt;a href=&quot;#project-structure&quot; class=&quot;header-anchor&quot;&gt;Project Structure&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;My Playwright setup is organized in a dedicated &lt;code&gt;playwright/&lt;/code&gt; directory within the project:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;plaintext&quot; id=&quot;code-1795777174495-moiid7iz4&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;plaintext&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;playwright/
├── tests/
│   ├── home.spec.ts
│   ├── navigation.spec.ts
│   ├── auth.spec.ts
│   ├── login.spec.ts
│   ├── leaderboard.spec.ts
│   └── utils/
│       ├── test-helpers.ts
│       ├── auth-helpers.ts
│       ├── constants.ts
│       └── index.ts
├── playwright.config.ts
├── package.json
├── install.sh
└── test-workflow.sh
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;This structure separates concerns and makes the test suite maintainable and scalable.&lt;br&gt;&lt;h2 id=&quot;configuration-setup&quot;&gt;&lt;a href=&quot;#configuration-setup&quot; class=&quot;header-anchor&quot;&gt;Configuration Setup&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The heart of my Playwright setup is the &lt;code&gt;playwright.config.ts&lt;/code&gt; file. Here&apos;s how I configured it for optimal performance and reliability:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-t7xtizgna&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { defineConfig, devices } from &amp;#x27;@playwright/test&amp;#x27;;
import path from &amp;#x27;node:path&amp;#x27;;
import process from &amp;#x27;node:process&amp;#x27;;
import { config } from &amp;#x27;dotenv&amp;#x27;;

// Load environment variables from .env file
config({ path: path.join(__dirname, &amp;#x27;.env&amp;#x27;), quiet: true });

export default defineConfig({
  testDir: &amp;#x27;./tests&amp;#x27;,
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: 2,
  workers: 1, // Single worker for CI stability
  timeout: 10000,

  reporter: [
    [&amp;#x27;html&amp;#x27;],
    [&amp;#x27;json&amp;#x27;, { outputFile: &amp;#x27;test-results.json&amp;#x27; }],
    [&amp;#x27;junit&amp;#x27;, { outputFile: &amp;#x27;test-results.xml&amp;#x27; }],
  ],

  use: {
    baseURL: process.env.CI
      ? &amp;#x27;https://retroranker.site&amp;#x27;
      : &amp;#x27;http://localhost:8000&amp;#x27;,

    trace: &amp;#x27;on-first-retry&amp;#x27;,
    navigationTimeout: 10000,
    actionTimeout: 10000,

    // Disable analytics tracking during tests
    storageState: {
      cookies: [],
      origins: [
        {
          origin: process.env.CI
            ? &amp;#x27;https://retroranker.site&amp;#x27;
            : &amp;#x27;http://localhost:8000&amp;#x27;,
          localStorage: [{ name: &amp;#x27;umami.disabled&amp;#x27;, value: &amp;#x27;1&amp;#x27; }],
        },
      ],
    },
  },

  projects: process.env.CI
    ? [
        // CI: Test Chrome desktop and mobile for speed
        { name: &amp;#x27;chromium&amp;#x27;, use: { ...devices[&amp;#x27;Desktop Chrome&amp;#x27;] } },
        { name: &amp;#x27;Mobile Chrome&amp;#x27;, use: { ...devices[&amp;#x27;Pixel 5&amp;#x27;] } },
      ]
    : [
        // Local: Test all browsers for comprehensive coverage
        { name: &amp;#x27;chromium&amp;#x27;, use: { ...devices[&amp;#x27;Desktop Chrome&amp;#x27;] } },
        { name: &amp;#x27;firefox&amp;#x27;, use: { ...devices[&amp;#x27;Desktop Firefox&amp;#x27;] } },
        { name: &amp;#x27;webkit&amp;#x27;, use: { ...devices[&amp;#x27;Desktop Safari&amp;#x27;] } },
        { name: &amp;#x27;Mobile Chrome&amp;#x27;, use: { ...devices[&amp;#x27;Pixel 5&amp;#x27;] } },
        { name: &amp;#x27;Mobile Safari&amp;#x27;, use: { ...devices[&amp;#x27;iPhone 12&amp;#x27;] } },
      ],

  // Auto-start dev server for local development
  ...(process.env.CI
    ? {}
    : {
        webServer: {
          command: &amp;#x27;deno task start&amp;#x27;,
          cwd: path.join(__dirname, &amp;#x27;..&amp;#x27;),
          url: &amp;#x27;http://localhost:8000&amp;#x27;,
          reuseExistingServer: true,
        },
      }),
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Key configuration highlights:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Environment-aware base URL&lt;/strong&gt;: Uses localhost for development, production URL for CI&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Analytics disabling&lt;/strong&gt;: Prevents test runs from polluting analytics data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Conditional browser testing&lt;/strong&gt;: Full browser suite locally, optimized set for CI&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Auto-server startup&lt;/strong&gt;: Automatically starts the Deno dev server for local testing&lt;/li&gt;
&lt;/ul&gt; &lt;h2 id=&quot;test-helper-architecture&quot;&gt;&lt;a href=&quot;#test-helper-architecture&quot; class=&quot;header-anchor&quot;&gt;Test Helper Architecture&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;One of the most powerful aspects of my setup is the comprehensive helper utilities that make tests more readable and maintainable. The architecture is built around three core components:&lt;br&gt;&lt;h3 id=&quot;testhelpers-class&quot;&gt;&lt;a href=&quot;#testhelpers-class&quot; class=&quot;header-anchor&quot;&gt;TestHelpers Class&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The &lt;code&gt;TestHelpers&lt;/code&gt; class provides robust navigation and interaction methods:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-ggo5fiqcc&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;export class TestHelpers {
  constructor(private page: Page) {}

  async navigateTo(
    path: string,
    options?: {
      waitForSelector?: string;
      timeout?: number;
      waitForLoadState?: &amp;#x27;load&amp;#x27; | &amp;#x27;domcontentloaded&amp;#x27; | &amp;#x27;networkidle&amp;#x27;;
      waitUntil?: &amp;#x27;load&amp;#x27; | &amp;#x27;domcontentloaded&amp;#x27; | &amp;#x27;networkidle&amp;#x27; | &amp;#x27;commit&amp;#x27;;
    }
  ) {
    const {
      waitForSelector = &amp;#x27;main, body&amp;#x27;,
      timeout = 10000,
      waitForLoadState = &amp;#x27;domcontentloaded&amp;#x27;,
      waitUntil = &amp;#x27;domcontentloaded&amp;#x27;,
    } = options || {};

    // Check if page is still open before navigation
    this.checkPageOpen();

    await this.page.goto(path, { waitUntil });

    // Wait for the specified load state
    try {
      await this.page.waitForLoadState(waitForLoadState, { timeout });
    } catch (error) {
      console.log(
        `Warning: Load state &amp;#x27;${waitForLoadState}&amp;#x27; timed out for ${path}`
      );
    }

    // Wait for key element to be visible
    try {
      await this.page.waitForSelector(waitForSelector, {
        state: &amp;#x27;visible&amp;#x27;,
        timeout,
      });
    } catch (error) {
      // Fallback to body if specific selector fails
      await this.page.waitForSelector(&amp;#x27;body&amp;#x27;, {
        state: &amp;#x27;visible&amp;#x27;,
        timeout: 5000,
      });
    }
  }

  async testResponsiveDesign() {
    // Desktop
    await this.page.setViewportSize({ width: 1280, height: 720 });
    await expect(this.page.locator(&amp;#x27;body&amp;#x27;)).toBeVisible();

    // Tablet
    await this.page.setViewportSize({ width: 768, height: 1024 });
    await expect(this.page.locator(&amp;#x27;body&amp;#x27;)).toBeVisible();

    // Mobile
    await this.page.setViewportSize({ width: 375, height: 667 });
    await expect(this.page.locator(&amp;#x27;body&amp;#x27;)).toBeVisible();
  }

  async clickElement(selector: string) {
    await this.page.waitForSelector(selector, { state: &amp;#x27;visible&amp;#x27; });
    await this.page.click(selector);
  }

  async fillField(selector: string, value: string) {
    await this.page.waitForSelector(selector, { state: &amp;#x27;visible&amp;#x27; });
    await this.page.fill(selector, value);
  }

  async elementShouldBeVisible(selector: string) {
    await expect(this.page.locator(selector)).toBeVisible();
  }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;The helper utilities provide:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Robust navigation&lt;/strong&gt;: Handles timeouts and fallbacks gracefully&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Responsive testing&lt;/strong&gt;: Easy viewport switching for mobile/desktop testing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Element interactions&lt;/strong&gt;: Safe clicking and form filling with proper waits&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Error handling&lt;/strong&gt;: Comprehensive error checking and recovery&lt;/li&gt;
&lt;/ul&gt; &lt;h3 id=&quot;authhelpers-class&quot;&gt;&lt;a href=&quot;#authhelpers-class&quot; class=&quot;header-anchor&quot;&gt;AuthHelpers Class&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;For authentication flows, we have a specialized &lt;code&gt;AuthHelpers&lt;/code&gt; class:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-3aw0pl7xw&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;export class AuthHelpers {
  constructor(private page: Page) {}

  async loginWithEnvCredentials() {
    const nickname = process.env.TEST_USER_NICKNAME;
    const password = process.env.TEST_USER_PASSWORD;

    if (!nickname || !password) {
      throw new Error(
        &amp;#x27;TEST_USER_NICKNAME and TEST_USER_PASSWORD must be set in .env file&amp;#x27;
      );
    }

    await this.page.goto(&amp;#x27;/auth/sign-in&amp;#x27;);
    await this.page.waitForLoadState(&amp;#x27;networkidle&amp;#x27;);

    // Verify CSRF token is present
    await expect(this.page.locator(&amp;#x27;input[name=&amp;quot;csrf_token&amp;quot;]&amp;#x27;)).toHaveValue(
      /^.+$/
    );

    // Fill in the login form
    await this.page.fill(&amp;#x27;input[name=&amp;quot;nickname&amp;quot;]&amp;#x27;, nickname);
    await this.page.fill(&amp;#x27;input[name=&amp;quot;password&amp;quot;]&amp;#x27;, password);

    // Submit the form and wait for navigation
    await Promise.all([
      this.page.waitForURL(/\/profile/, { timeout: 10000 }),
      this.page.click(&amp;#x27;button[type=&amp;quot;submit&amp;quot;]&amp;#x27;),
    ]);

    await this.page.waitForLoadState(&amp;#x27;networkidle&amp;#x27;);
  }

  async isLoggedIn(): Promise&amp;lt;boolean&amp;gt; {
    try {
      // Check if we&amp;#x27;re on the profile page
      if (this.page.url().includes(&amp;#x27;/profile&amp;#x27;)) {
        return true;
      }

      // Check if we&amp;#x27;re on mobile or desktop
      const isMobile = await this.page.locator(&amp;#x27;.mobile-nav&amp;#x27;).isVisible();

      if (isMobile) {
        // On mobile, check if profile link exists in the mobile menu
        const mobileProfileElements = await this.page
          .locator(&amp;#x27;.mobile-nav-content [href=&amp;quot;/profile&amp;quot;]&amp;#x27;)
          .count();
        return mobileProfileElements &amp;gt; 0;
      } else {
        // On desktop, check for user-specific elements in navigation
        const userElements = await this.page
          .locator(&amp;#x27;[href=&amp;quot;/profile&amp;quot;]&amp;#x27;)
          .count();
        return userElements &amp;gt; 0;
      }
    } catch {
      return false;
    }
  }

  async logout() {
    await this.page.goto(&amp;#x27;/api/auth/sign-out&amp;#x27;, {
      waitUntil: &amp;#x27;domcontentloaded&amp;#x27;,
    });
  }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;The &lt;code&gt;AuthHelpers&lt;/code&gt; class provides:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Environment-based login&lt;/strong&gt;: Uses credentials from environment variables&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Session state detection&lt;/strong&gt;: Intelligently detects login state across mobile/desktop&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CSRF token handling&lt;/strong&gt;: Manages CSRF tokens for secure form submissions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logout functionality&lt;/strong&gt;: Handles logout flows consistently&lt;/li&gt;
&lt;/ul&gt; &lt;h3 id=&quot;constants-management&quot;&gt;&lt;a href=&quot;#constants-management&quot; class=&quot;header-anchor&quot;&gt;Constants Management&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I use a centralized constants file to maintain consistent selectors across all tests:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-5wz0svtfu&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;/**
 * Common selectors for the application
 */
export const SELECTORS = {
  // General navigation
  NAVIGATION: &amp;#x27;nav&amp;#x27;,
  NAV_LINKS: &amp;#x27;nav a&amp;#x27;,
  MAIN_CONTENT: &amp;#x27;main&amp;#x27;,

  // Desktop navigation
  DESKTOP_NAV: &amp;#x27;.desktop-nav&amp;#x27;,
  DESKTOP_NAV_LINKS: &amp;#x27;.desktop-nav a[href]&amp;#x27;,
  DESKTOP_SEARCH: &amp;#x27;.nav-search-item input&amp;#x27;,
  DESKTOP_SEARCH_BUTTON: &amp;#x27;.search-button&amp;#x27;,

  // Mobile navigation
  MOBILE_NAV: &amp;#x27;.mobile-nav&amp;#x27;,
  MOBILE_NAV_CONTENT: &amp;#x27;.mobile-nav-content&amp;#x27;,
  MOBILE_NAV_LINKS: &amp;#x27;.mobile-nav-content a[href]&amp;#x27;,
  BURGER_MENU: &amp;#x27;.burger-menu&amp;#x27;,
  MOBILE_SEARCH_CONTAINER: &amp;#x27;.mobile-nav-search-container&amp;#x27;,
  MOBILE_SEARCH_INPUT: &amp;quot;.mobile-nav-search-container input[type=&amp;#x27;search&amp;#x27;]&amp;quot;,
  MOBILE_SEARCH_BUTTON: &amp;#x27;.search-button-mobile&amp;#x27;,
  MOBILE_CONTROLS: &amp;#x27;.mobile-nav-controls&amp;#x27;,

  // Form elements
  FORM: &amp;#x27;form&amp;#x27;,
  EMAIL_INPUT: &amp;#x27;input[type=&amp;quot;email&amp;quot;], input[name=&amp;quot;email&amp;quot;]&amp;#x27;,
  NICKNAME_INPUT: &amp;#x27;input[name=&amp;quot;nickname&amp;quot;], input[type=&amp;quot;text&amp;quot;]&amp;#x27;,
  PASSWORD_INPUT: &amp;#x27;input[name=&amp;quot;password&amp;quot;]&amp;#x27;,
  CONFIRM_PASSWORD_INPUT: &amp;#x27;input[name=&amp;quot;confirmPassword&amp;quot;]&amp;#x27;,
  SUBMIT_BUTTON: &amp;#x27;button[type=&amp;quot;submit&amp;quot;], input[type=&amp;quot;submit&amp;quot;]&amp;#x27;,
  ERROR_MESSAGE: &amp;#x27;.error, [data-testid=&amp;quot;error&amp;quot;]&amp;#x27;,
  SUCCESS_MESSAGE: &amp;#x27;.success, [data-testid=&amp;quot;success&amp;quot;]&amp;#x27;,
  AUTH_FORM: &amp;#x27;.auth-form&amp;#x27;,
  OAUTH_BUTTONS: &amp;#x27;.auth-signin-btn&amp;#x27;,
} as const;

/**
 * Common test data
 */
export const TEST_DATA = {
  VALID_EMAIL: &amp;#x27;test@example.com&amp;#x27;,
  VALID_PASSWORD: &amp;#x27;password123&amp;#x27;,
  INVALID_EMAIL: &amp;#x27;invalid-email&amp;#x27;,
  INVALID_PASSWORD: &amp;#x27;123&amp;#x27;,
} as const;
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;This allows me to write tests using consistent selectors and makes maintenance much easier.&lt;br&gt;&lt;h2 id=&quot;writing-effective-tests&quot;&gt;&lt;a href=&quot;#writing-effective-tests&quot; class=&quot;header-anchor&quot;&gt;Writing Effective Tests&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;With our helper utilities in place, writing tests becomes much cleaner and more maintainable. Let&apos;s look at examples from different types of tests.&lt;br&gt;&lt;h3 id=&quot;home-page-tests&quot;&gt;&lt;a href=&quot;#home-page-tests&quot; class=&quot;header-anchor&quot;&gt;Home Page Tests&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Here&apos;s an example from our home page tests:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-pcwth6q4i&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { expect, test } from &amp;#x27;@playwright/test&amp;#x27;;
import { createTestHelper } from &amp;#x27;./utils/index.ts&amp;#x27;;

test.describe(&amp;#x27;Home Page&amp;#x27;, () =&amp;gt; {
  test(&amp;#x27;should load the home page with correct title and meta&amp;#x27;, async ({
    page,
  }) =&amp;gt; {
    const helper = createTestHelper(page);
    await helper.navigateTo(&amp;#x27;/&amp;#x27;, {
      waitForLoadState: &amp;#x27;networkidle&amp;#x27;,
      waitForSelector: &amp;#x27;main.main-content&amp;#x27;,
    });

    // Check that the page has the correct title
    await helper.pageShouldHaveTitle(/Retro Ranker - Home/);

    // Check for meta description
    await expect(page.locator(&amp;#x27;meta[name=&amp;quot;description&amp;quot;]&amp;#x27;)).toHaveAttribute(
      &amp;#x27;content&amp;#x27;,
      /Retro Ranker - Home to browse and compare retro gaming handhelds/
    );
  });

  test(&amp;#x27;should display hero section with main content&amp;#x27;, async ({ page }) =&amp;gt; {
    const helper = createTestHelper(page);
    await helper.navigateTo(&amp;#x27;/&amp;#x27;);

    // Check for hero container
    await helper.elementShouldBeVisible(&amp;#x27;.hero-container&amp;#x27;);

    // Check for main heading with &amp;quot;Retro Ranker&amp;quot;
    await expect(page.locator(&amp;#x27;h1&amp;#x27;)).toContainText(&amp;#x27;Retro Ranker&amp;#x27;);

    // Check for hero description
    await helper.elementShouldBeVisible(&amp;#x27;.hero-section p&amp;#x27;);

    // Check for join community button
    await helper.elementShouldBeVisible(
      &amp;#x27;.hero-section a[href=&amp;quot;/auth/sign-in&amp;quot;]&amp;#x27;
    );
  });

  test(&amp;#x27;should be responsive across different viewport sizes&amp;#x27;, async ({
    page,
  }) =&amp;gt; {
    const helper = createTestHelper(page);
    await helper.navigateTo(&amp;#x27;/&amp;#x27;);

    // Test responsive design with helper
    await helper.testResponsiveDesign();
  });
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h3 id=&quot;authentication-tests&quot;&gt;&lt;a href=&quot;#authentication-tests&quot; class=&quot;header-anchor&quot;&gt;Authentication Tests&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;For authentication flows, I use specialized &lt;code&gt;AuthHelpers&lt;/code&gt;:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-4pa7ch57a&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { expect, test } from &amp;#x27;@playwright/test&amp;#x27;;
import process from &amp;#x27;node:process&amp;#x27;;
import { createAuthHelper, createTestHelper } from &amp;#x27;./utils/index.ts&amp;#x27;;

test.describe(&amp;#x27;Login Functionality&amp;#x27;, () =&amp;gt; {
  test(&amp;#x27;should login successfully with valid credentials from .env&amp;#x27;, async ({
    page,
  }) =&amp;gt; {
    const authHelper = createAuthHelper(page);

    // Check if credentials are available
    const nickname = process.env.TEST_USER_NICKNAME;
    const password = process.env.TEST_USER_PASSWORD;

    if (!nickname || !password) {
      test.skip(); // Skip test if credentials not available
      return;
    }

    // Perform login using helper
    await authHelper.loginWithEnvCredentials();

    // Verify we&amp;#x27;re logged in
    expect(await authHelper.isLoggedIn()).toBe(true);

    // Check we&amp;#x27;re on the profile page
    await expect(page).toHaveURL(/\/profile/);
  });
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h3 id=&quot;using-helper-functions&quot;&gt;&lt;a href=&quot;#using-helper-functions&quot; class=&quot;header-anchor&quot;&gt;Using Helper Functions&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The helper functions make tests much more readable and maintainable:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-66juh2gp6&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;import { SELECTORS, TEST_DATA } from &amp;#x27;./utils/constants.ts&amp;#x27;;

test(&amp;#x27;should handle form validation&amp;#x27;, async ({ page }) =&amp;gt; {
  const helper = createTestHelper(page);
  await helper.navigateTo(&amp;#x27;/auth/sign-in&amp;#x27;);

  // Use constants for selectors
  await helper.elementShouldBeVisible(SELECTORS.AUTH_FORM);
  await helper.elementShouldBeVisible(SELECTORS.NICKNAME_INPUT);
  await helper.elementShouldBeVisible(SELECTORS.PASSWORD_INPUT);

  // Fill form using constants
  await helper.fillField(SELECTORS.NICKNAME_INPUT, &amp;#x27;testuser&amp;#x27;);
  await helper.fillField(SELECTORS.PASSWORD_INPUT, TEST_DATA.VALID_PASSWORD);

  // Submit form
  await helper.clickElement(SELECTORS.SUBMIT_BUTTON);
});
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;Key testing patterns I follow:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use helper functions&lt;/strong&gt;: Encapsulate common operations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test user workflows&lt;/strong&gt;: Focus on real user interactions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Responsive testing&lt;/strong&gt;: Ensure mobile and desktop compatibility&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accessibility checks&lt;/strong&gt;: Verify page structure and content&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Error scenarios&lt;/strong&gt;: Test edge cases and error handling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Environment-aware testing&lt;/strong&gt;: Skip tests when dependencies aren&apos;t available&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Session management&lt;/strong&gt;: Handle login/logout flows consistently&lt;/li&gt;
&lt;/ul&gt; &lt;h2 id=&quot;ci-cd-integration&quot;&gt;&lt;a href=&quot;#ci-cd-integration&quot; class=&quot;header-anchor&quot;&gt;CI/CD Integration&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;My Playwright setup integrates seamlessly with GitHub Actions for automated testing. There are 2 versions:&lt;/p&gt;&lt;p&gt;&lt;ol&gt;
&lt;li&gt;runs on every main/develop PR/push&lt;/li&gt;
&lt;li&gt;runs every night&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;The playwright configuration automatically adapts to the CI environment:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;yaml&quot; id=&quot;code-1795777174496-jga7ohy2f&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;yaml&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;# .github/workflows/playwright-tests.yml
name: 🧪 Playwright Tests

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main, develop]
  workflow_dispatch:

concurrency:
  group: playwright-tests-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    name: Run Playwright Tests
    runs-on: ubuntu-latest
    timeout-minutes: 30

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: &amp;quot;20&amp;quot;
          cache: &amp;quot;npm&amp;quot;
          cache-dependency-path: playwright/package-lock.json

      - name: Cache Playwright browsers
        uses: actions/cache@v4
        id: cache-playwright
        with:
          path: |
            ~/.cache/ms-playwright
            playwright/.cache
          key: ${{ runner.os }}-playwright-${{ hashFiles(&amp;#x27;playwright/package-lock.json&amp;#x27;) }}
          restore-keys: |
            ${{ runner.os }}-playwright-

      - name: Install Playwright dependencies
        working-directory: playwright
        run: npm ci

      - name: Install Playwright browsers
        working-directory: playwright
        run: npx playwright install --with-deps
        if: steps.cache-playwright.outputs.cache-hit != &amp;#x27;true&amp;#x27;

      - name: Create screenshots directory
        run: mkdir -p playwright/screenshots

      - name: Run Playwright tests
        working-directory: playwright
        run: npm test
        env:
          CI: true
          TEST_USER_NICKNAME: ${{ secrets.TEST_USER_NICKNAME }}
          TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
          TEST_USER_2_NICKNAME: ${{ secrets.TEST_USER_2_NICKNAME }}
          TEST_USER_2_PASSWORD: ${{ secrets.TEST_USER_2_PASSWORD }}

      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-test-results-${{ github.run_number }}
          path: |
            playwright/test-results/
            playwright/playwright-report/
          retention-days: 30

      - name: Upload screenshots
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-screenshots-${{ github.run_number }}
          path: playwright/screenshots/
          retention-days: 30

    ...

&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;p&gt;The CI setup provides:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Automated testing&lt;/strong&gt;: Runs on every PR and push&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Artifact storage&lt;/strong&gt;: Preserves test reports and screenshots&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Caching&lt;/strong&gt;: Speeds up builds with dependency caching&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-browser testing&lt;/strong&gt;: Ensures cross-browser compatibility&lt;/li&gt;
&lt;/ul&gt; &lt;h2 id=&quot;best-practices-and-patterns&quot;&gt;&lt;a href=&quot;#best-practices-and-patterns&quot; class=&quot;header-anchor&quot;&gt;Best Practices and Patterns&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Throughout my Playwright implementation, I&apos;ve established several best practices:&lt;br&gt;&lt;h3 id=&quot;1-environment-configuration&quot;&gt;&lt;a href=&quot;#1-environment-configuration&quot; class=&quot;header-anchor&quot;&gt;1. Environment Configuration&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-k3jvmxejg&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// Use environment variables for different contexts
baseURL: process.env.CI
  ? &amp;quot;https://retroranker.site&amp;quot;
  : &amp;quot;http://localhost:8000&amp;quot;,
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h3 id=&quot;2-robust-waiting-strategies&quot;&gt;&lt;a href=&quot;#2-robust-waiting-strategies&quot; class=&quot;header-anchor&quot;&gt;2. Robust Waiting Strategies&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The test- and auth- helpers are filled with these!&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-m2mdshys5&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// Wait for content with fallbacks
async navigateTo(path: string, options?: {
  waitForSelector?: string;
  timeout?: number;
}) {
  // Primary wait strategy
  try {
    await this.page.waitForSelector(waitForSelector, { timeout });
  } catch (error) {
    // Fallback to body
    await this.page.waitForSelector(&amp;quot;body&amp;quot;, { timeout: 5000 });
  }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h3 id=&quot;3-test-data-management&quot;&gt;&lt;a href=&quot;#3-test-data-management&quot; class=&quot;header-anchor&quot;&gt;3. Test Data Management&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;Using Constants for selectors and test data&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;.env&lt;/code&gt; files locally for credentials&lt;/li&gt;
&lt;li&gt;Use pipeline secrets in CI for credentials&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-1x7zygwqk&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// Use environment variables for test credentials
const nickname = process.env.TEST_USER_NICKNAME;
const password = process.env.TEST_USER_PASSWORD;

if (!nickname || !password) {
  test.skip(); // Skip test if credentials not available
  return;
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h3 id=&quot;4-error-handling-and-recovery&quot;&gt;&lt;a href=&quot;#4-error-handling-and-recovery&quot; class=&quot;header-anchor&quot;&gt;4. Error Handling and Recovery&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-8a6qr1h4w&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// Safe element interactions
async safeClick(selector: string, options?: { timeout?: number }) {
  try {
    if (this.page.isClosed()) {
      throw new Error(&amp;quot;Page has been closed&amp;quot;);
    }
    await this.page.click(selector, { timeout });
  } catch (error) {
    // Handle page closure errors gracefully
    if (error.message.includes(&amp;quot;Target page, context or browser has been closed&amp;quot;)) {
      throw new Error(`Page was closed during click on ${selector}`);
    }
    throw error;
  }
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h3 id=&quot;5-responsive-testing&quot;&gt;&lt;a href=&quot;#5-responsive-testing&quot; class=&quot;header-anchor&quot;&gt;5. Responsive Testing&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;div class=&quot;code-block-container&quot; data-language=&quot;typescript&quot; id=&quot;code-1795777174496-vy9ivgg9b&quot;&gt;
            &lt;div class=&quot;code-block-header&quot;&gt;
                &lt;span class=&quot;language-label&quot;&gt;typescript&lt;/span&gt;
                &lt;button class=&quot;copy-button&quot; type=&quot;button&quot;&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
            &lt;pre&gt;&lt;code class=&quot;language-typescript&quot;&gt;// Test across different viewport sizes
async testResponsiveDesign() {
  // Desktop
  await this.page.setViewportSize({ width: 1280, height: 720 });
  await expect(this.page.locator(&amp;quot;body&amp;quot;)).toBeVisible();

  // Tablet
  await this.page.setViewportSize({ width: 768, height: 1024 });
  await expect(this.page.locator(&amp;quot;body&amp;quot;)).toBeVisible();

  // Mobile
  await this.page.setViewportSize({ width: 375, height: 667 });
  await expect(this.page.locator(&amp;quot;body&amp;quot;)).toBeVisible();
}
&lt;/code&gt;&lt;/pre&gt;
        &lt;/div&gt;&lt;br&gt;&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;header-anchor&quot;&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Setting up Playwright for Retro Ranker has provided me with a robust, maintainable testing solution that scales with my application. The key benefits I&apos;ve achieved include:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Comprehensive coverage&lt;/strong&gt;: Multi-browser testing across desktop and mobile&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Developer experience&lt;/strong&gt;: Clean, readable tests with helpful utilities&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CI/CD integration&lt;/strong&gt;: Automated testing with detailed reporting&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Maintainability&lt;/strong&gt;: Well-structured code with clear separation of concerns&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reliability&lt;/strong&gt;: Robust error handling and recovery mechanisms&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;The combination of thoughtful configuration, comprehensive helper utilities, and established testing patterns has created a testing suite that not only catches bugs but also serves as living documentation of my application&apos;s expected behavior.&lt;/p&gt;&lt;p&gt;Whether you&apos;re building a Fresh/Deno application like Retro Ranker or working with any modern web framework, Playwright provides the tools you need to build confidence in your application&apos;s quality and reliability.&lt;/p&gt;&lt;p&gt;For more details about my specific implementation, check out the &lt;a href=&quot;https://github.com/nergy101/retro-ranker&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Retro Ranker repository&lt;/a&gt; and explore the &lt;code&gt;playwright/&lt;/code&gt; directory to see how these patterns work in practice.
            &lt;/div&gt;</content>
  </entry>
  <entry>
    <title>Welcome to my Blog</title>
    <link href="https://blog.nergy.space/blogs/the-first-post"/>
    <id>https://blog.nergy.space/blogs/the-first-post</id>
    <published>2024-11-27T00:00:00.000Z</published>
    <updated>2024-11-27T00:00:00.000Z</updated>
    <author><name>Christian / Nergy101</name></author>
    <summary>This will mark my first post as I begin my Blogging journey in the tech industry.</summary>
    <content type="html">&lt;div class=&quot;container&quot;&gt;
                &lt;h1 id=&quot;welcome-to-my-blog&quot;&gt;&lt;a href=&quot;#welcome-to-my-blog&quot; class=&quot;header-anchor&quot;&gt;Welcome to my Blog&lt;/a&gt;&lt;/h1&gt;&lt;p&gt;This will mark my first post as I begin my Blogging journey in the tech industry.&lt;/p&gt;&lt;p&gt;As a professional Software Engineer for about 5 years now, I&apos;m increasingly finding out how I enjoy sharing knowledge and teaching others...&lt;/p&gt;&lt;p&gt;More than anything else!&lt;/p&gt;&lt;p&gt;I&apos;m excited about what we will explore and learn.&lt;/p&gt;&lt;p&gt;If you are too, feel free to follow my github profile or subscribe to the blog.&lt;/p&gt;&lt;p&gt;Cheers!
            &lt;/div&gt;</content>
  </entry>
</feed>
