0.34.0
elements man changelog/v0-34-0Queries are run with db.query and transactions with db.tx, and SQL text is
always written in a template. A LiveTable custom select returns a query and
Elements runs it. Browser code reads an env file value through config.jsoc
and not through process.env. This release and @elements/app 0.30.0 go
together: upgrade the package in every project after upgrading Elements.
Changes
db.queryruns a query. It replacessql(). Write the SQL as a template directly after it, with no parentheses:db.query<User>`select * from users where id = ${id}`. It does not accept a string. Requires@elements/app0.30.0.db.tx(fn)runsfnin a transaction. It replacestx(). The async variants aredb.queryAsyncanddb.txAsync, replacingsqlAsyncandtxAsync.sqlbuilds a part of a query and does not run it.sql`and createdAt < ${cursor}`returns aSql, which you place in adb.querytemplate or in anothersqltemplate with${}.db.query(part)runs aSqlthat a function built.sql.join(parts, separator)joins an array ofSqlvalues.sql.ident(name)returns aSqlwhose text is the column or table name in the stringname, and throws when the string is anything other than a name.sql.rawis removed.sqlreplaces it for SQL text written in your code, andsql.identreplaces it for a name held in a variable.- A connection from
checkoutDb()hasqueryandtxin place ofsqlandtx:conn.query`select 1`. - A LiveTable custom
selectreturns a query written withsqland does not run it. It takes the partition and no second argument. Elements adds the ORDER BY, the LIMIT and the condition for the next page outside your query, sow.keyset(),w.order()andw.page()are removed, and so is theSelectWindowtype. - After a write to a LiveTable with a custom
select, Elements runs that select for the written row and sends each browser the row the select returns. The browser receives the columns the select returns, and does not receive a row the select does not return. - The server sends a windowed view only the written rows that sort inside the range the view has loaded.
new LiveTable(config)gets its table name from the variable it is assigned to whenconfigis declared in another statement, the same as when the config is written in the call.- In your project's browser code, the one allowed use of
process.envisENVorNODE_ENVcompared with a literal, as inprocess.env.ENV === "production". Every other read is compile error 230047:process.env.X,process.env["X"],process.env[NAME]whereNAMEis a JavaScript variable, a comparison on another variable, andENVorNODE_ENVread without a comparison. In an installed package's browser code each of those reads is written asundefined. - In browser code,
NODE_ENVis the active environment's name when the env file and the build server's environment do not set it. SetNODE_ENVin an env file to give it another value. - A read of a config key that holds a string, a number, a boolean or null is written as that value in the emitted code.
- In a function that runs in the browser, passing a server function by name,
as in
setTimeout(deleteUserRows, 10), is compile error 230001, as calling it is. - The shorthand attribute
{name}on an element is type checked asname={name}is. - An
e:elseifore:elseelement can have a comment between it and the branch before it. - An
e:elseifore:elseelement with text, an interpolation or another element between it and the branch before it, or with noe:ifbefore it, is compile error 230048. e:keyon a template call is checked as it is on an element.<Card e:for={row of rows} e:key={row.id} />is compile error 230046.- An error that says what to try has a
tryarray and aseestring in-json, and itsmessageno longer contains the fixes or the manual page name. Eachtryentry has atextsentence, acodeexample, acommandto run on the command line, or several of them.seeis the name of a manual page: for"config", runelements man config. The terminal lists each entry underTry:with a dash, and writes>before a command. - When a newer release exists,
elements buildandelements startprint a line, and that line now has the address of the changelog on elements.dev:Elements version 0.35.0 is available. Read https://elements.dev/man/changelog before you run elements upgrade.elements build -jsonhas the address inchangelogand the version inupgrade.elements man changelogsays which changelog pages to read before you runelements upgrade. - The recipe in
elements man browserstarts headless Chrome, runs the checks and closes Chrome withBrowser.closein one script. Chrome deletes its profile folder when it is closed withBrowser.close. - In VS Code, the file explorer of an Elements project does not list the
.elementsfolder or the.claude,.codex,.gemini,.cursorand.vscodefolders, unless the workspace has its ownfiles.excludesetting. elements issue listlists the issues you filed, voted for or commented on, with the issue that changed last first.-state=resolved,releasedkeeps the issues in those states,-since=2026-11-01keeps the issues that changed on or after that date, and-limitsets how many are listed. It replaceselements issue search -mine, which is removed. Seeelements man issues.- Every command, option and example description in
elements helpis one short line.
Upgrade
Every call to a removed function is a type error after @elements/app is
upgraded, so elements build -json lists each place to change. Make the
changes in this order, then build until the error count is zero.
-
Upgrade
@elements/appin each project. With an older@elements/appinstalled, the build reports error 220017, which names the package and the versions this release works with. A project that pins@elements/appto an exact version changes the pin to0.30.0or later inconfig.jsocfirst. Restartelements startafter the install.Terminalelements install @elements/app -u -json elements build -json -
Rewrite each query call. The template is unchanged; the name changes and the parentheses are removed.
Query call// before let user = sql<User>(`select * from users where id = ${id}`).first(); // after let user = db.query<User>`select * from users where id = ${id}`.first();sqlAsync<T>(...)becomesdb.queryAsync<T>`...`the same way. -
Rewrite
tx(todb.tx(andtxAsync(todb.txAsync(. -
Rewrite each
sql.raw. Text written in your code becomes asqltemplate. A column or table name held in a variable becomessql.ident.sql.raw// before let older = cursor ? sql.raw(`and createdAt < ${cursor}`) : sql.raw(""); let column = sql.raw(sortColumn); // after let older = cursor ? sql`and createdAt < ${cursor}` : sql``; let column = sql.ident(sortColumn); -
Fix the imports from
@elements/app. Adddbto every file that now callsdb.queryordb.tx. Removetx,sqlAsyncandtxAsync. Keepsqlonly in a file that still writes asqltemplate. -
Rename any local variable named
db. Afterusing db = checkoutDb(),dbin the enclosing block is the connection and not the importeddb. Name the connectionconn, and changeconn.sql(...)toconn.query`...`. -
Rewrite each LiveTable custom
select. Return asqltemplate in place of thesql()call, remove the second parameter, and delete thew.keyset()condition, theorder by ${w.order()}line and the${w.page()}line. The query must returnid, each partition column and eachorderBycolumn.Custom select// before select: ({ roomId }, w) => sql<Message>(` select m.* from messages m where m.roomId = ${roomId} and ${w.keyset("m")} order by ${w.order("m")} ${w.page()} `), // after select: ({ roomId }) => sql` select m.* from messages m where m.roomId = ${roomId} `, -
A template
filter()that hides rows a customselectalready excludes can be deleted, because those rows are no longer sent to the browser. -
For each
process.envread in browser code that the build reports, add a key toconfig.jsocthat holdsenv("X")with the@browserbuild tag, and read the key in place ofprocess.env.X.config.jsoc{ /** @browser */ stripePublishableKey: env("STRIPE_PUBLISHABLE_KEY"), }Browser code// before let key = process.env.STRIPE_PUBLISHABLE_KEY; // after let key = config.stripePublishableKey;
A query passed as a string in a variable, sql(text), has no direct
replacement. Write the query as a template where it is run, and build its
variable parts with sql, sql.join and sql.ident. See database/sql.