Bun is Back and Better Than Ever
TLDR
We restore and expand support for running Triplit in Bun and make a number of other improvements and bug fixes.
Bun is Back!
With the release of Triplit 1.0 we deprecated support for a few different runtimes and storage engines (with the intent of restoring them all over time). Last week we brought back support for Cloudflare and this week we're happy to announce that we have restored support for Bun. This means you can now run your Triplit applications on Bun and take advantage of its fast startup times.
You can run the Triplit development server as a Bun server with Bun-specific storage:
bunx --bun triplit dev --storage sqlite
This will automatically use the bun:sqlite storage engine.
You can also run the it in its own Docker container with the associated docker image.
Or you can create your own custom Bun server:
import { createBunServer } from '@triplit/server/bun';
const port = +(process.env.PORT || 8080);
const startServer = await createBunServer({
storage: 'sqlite',
verboseLogs: !!process.env.VERBOSE_LOGS,
jwtSecret: process.env.JWT_SECRET!,
projectId: process.env.PROJECT_ID,
externalJwtSecret: process.env.EXTERNAL_JWT_SECRET,
maxPayloadMb: process.env.MAX_BODY_SIZE,
});
const dbServer = startServer(port);
console.log('running on port', port);
process.on('SIGINT', function () {
dbServer.close(() => {
console.log('Shutting down server... ');
process.exit();
});
});
... And everything else is better
We made a number of other improvements and bug fixes in this release. Here are some highlights:
Live queries
- Calls to
clearPendingChangesForEntity
orclearPendingChangesAll
will now correctly update local subscriptions to reflect the negation of the changes. - Calling
TriplitClient.clear()
orTriplitClient.reset()
will now cause all associated query hooks (e.g.useQuery
,useQueryOne
, etc.) to re-fetch their data and reinitialize their loading states.
Schemas
- Defaults passed into an attribute definition e.g.
S.String({ default: 'foo' })
will now be more accurately validated at runtime to check that the default value is of the correct type. - Fixed an issue where
S.Json
type was not accepting non-primitive default values.
Frameworks
- Svelte: We've added the
useQueryOne
anduseEntity
hooks for our Svelte bindings. - React Native: With the release of
metro
v0.82.0, Triplit no longer requires a custommetro.config.js
file. The docs have been updated to reflect this.
Server
-
Fixed an issue where bulk inserting with the
POST /bulk-insert
endpoint was not correctly handling JSON payloads. -
Fixed an issue where refresh tokens were not working correctly for developers using
triplit.io
sync servers.
Query Engine
- Fixed an issue where entities in a client's cache with attributes that had been removed from the schema were not correctly loading when queried.