Engineering
Prices in colones and dollars, no surprises
How Porta shows prices in colones or dollars at the Central Bank rate: server-side conversion, filters across currencies and a first render that never guesses.
October 26, 2026 · 4 min read
In Costa Rica one house may be listed in dollars and the one next door in colones, and buyers want to compare them in the currency they think in. It looks like a matter of multiplying by the exchange rate. In practice, the hard part is making sure the same price does not change value depending on the screen, the moment or who is looking.
One source for the exchange rate
The exchange rate comes from the Central Bank of Costa Rica, which publishes the daily reference buy and sell rates as economic indicators. Every day at 2:00 a.m. Costa Rica time, a scheduled AWS Lambda function asks the backend to read those two indicators from the Central Bank's public API, and the backend stores one record per day with the buy and sell rates. Nothing in the frontend calls the Central Bank.
If the fetch fails one day, the backend keeps using the last valid rate and logs a warning once the value is more than two days old. We would rather show a price converted at yesterday's rate than a results page that does not load.
The server converts, the client never does
The most important rule is that the browser never converts prices. Every price query to the GraphQL API includes the currency the person wants to see, and the backend answers with two values: the listing's original price and the converted price. The frontend shows the converted one and keeps the original to know which currency the seller used.
Converting in one place rules out a whole class of bugs. If the client multiplied by its own copy of the rate, the results card, the listing page and an alert email could show three different numbers for the same house, each with a rate from a different moment.
Filtering by price across currencies
Filters have the same problem in reverse. If someone searches for houses under 200,000 dollars, listings priced in colones must be part of the comparison too. The backend's search service normalizes prices at query time with the same exchange-rate service, so a filter in dollars and one in colones return the same set of properties.
In the frontend, the price-range control always records which currency its numbers are in. When the person switches currency, the bounds they typed are cleared rather than reinterpreted: 200,000 in dollars means nothing useful in colones, and asking again beats guessing.
Two layers for the first render
Public pages are rendered on the server so they reach search engines, and anyone sharing a link, complete. The server does not know which currency the visitor prefers, because that preference lives in their browser or their profile. Guessing it, or caching one person's preference and showing it to someone else, would be worse than not trying.
So the first render always shows colones, Porta's base currency. After hydration, if the person chose dollars, the page asks for the prices again in that currency. A visitor who already prefers colones makes no extra request. Structured data and social cards publish the price in the listing's own currency, the one the seller entered.
Races between requests
Someone can switch from colones to dollars and back within a second. If the first response arrives after the second, the page would show prices in the wrong currency. Every price reload carries a request number and only the latest response is applied; older ones are dropped when they arrive.
There is a subtler detail. The React currency provider starts with the default value and adopts the stored preference in an effect, but child effects run before their parent's. A component that asked the context during its first render would read colones and reload nothing. On mount, components read the preference straight from local storage, which is synchronous and already correct; after that, the context is in charge.
What we learned
- A converted price is server data, not a presentation detail.
- Every new surface that shows server-rendered prices needs the second-layer reload, or it stays frozen in colones. We wrote it down as a team rule.
- Consistency is worth more than minute-by-minute precision: the reference rate changes once a day, and that is enough to compare properties.
If you want to see the result from the buyer's side, the currency selector is in Porta's top bar, and the help center guide explains how to use it.
Written by the Porta team with the help of artificial intelligence tools and checked against the sources cited in the text. If you spot an outdated figure, write to us from the Help Center.
Related articles
Engineering
How we built the Porta blog
Why the Porta blog runs on MDX in the repository, a typed registry and static pages, and what we watch for in SEO: hreflang, lastmod, RSS and structured data.
October 26, 2026 · 5 min read