Skip to main content
Learn how to query data from Bijection in a Vue app. This quickstart uses the JavaScript client directly: BijectionClient.onUpdate subscribes to a query and updates a Vue ref. See Vue for other options.
1

Install the Bijection CLI

See Install Bijection for PATH setup and supported platforms.
2

Create a Vue site

Create a Vue site using the npm create vue@latest my-vue-app command.Bijection will work with any set of options but to follow this quickstart most closely choose:
  • Yes to “Add TypeScript?”
  • No to everything else

3

Add a Bijection backend

In the site’s directory, run bijection init. It adds a bijection/ folder, where you write your backend functions, with a sample schema, query and mutation, and bijection.json.
4

Add the Bijection SDK to the site

The Bijection SDK (bijection/react, bijection/browser, …) is not published to the npm registry. Your app declares it as a tarball from bijection.com, for the version of your CLI (bijection --version prints it). Add this line to the dependencies in your app’s package.json:
package.json
Then install your app’s dependencies with its package manager as usual (for example npm install). The react-vite and nextjs templates of bijection init write this line and run the install for you.
5

Set up a Bijection dev deployment

Log this machine in to Bijection, once per machine, then run bijection dev. The first run creates your dev deployment and saves its URL in .env.local as VITE_BIJECTION_URL. The dev command then keeps running to push your functions in bijection/ to your dev deployment on every change.
Bijection’s hosted service is not yet open for public sign-up, and the CLI has no default management service. Before running bijection login, set BIJECTION_MANAGEMENT_URL to the management service URL you were given, in your shell’s startup file so that every later bijection command sees it too:
6

Create sample data for your database

In a new terminal window, create a sampleData.jsonl file with some sample data.
7

Add the sample data to your database

Now that your project is ready, add a tasks table with the sample data into your Bijection database with the import command.
8

Declare the tasks table

bijection init created bijection/schema.ts, which declares the tables of your database, starting with a sample messages table. Add a tasks table beside it. The schema gives your functions TypeScript types, and Bijection enforces it at runtime.
bijection/schema.ts
9

Expose a database query

Add a new file tasks.ts in the bijection/ folder with a query function that loads the data.Exporting a query function from this file declares an API function named after the file and the export name, api.tasks.get.
10

Create the Bijection client

In a new file src/bijection.ts, create one BijectionClient for your deployment, shared by every component.
src/bijection.ts
11

Display the data in your app

In src/App.vue, subscribe to your api.tasks.get API function with onUpdate. The callback runs with the first result and again whenever the tasks change; unsubscribe when the component unmounts.
src/App.vue
12

Start the app

Start the app, open http://localhost:5173 in a browser, and see the list of tasks.
See the JavaScript client for mutations, actions and the rest of BijectionClient.