Instead of syncing code to a Bijection dev deployment hosted in the cloud, you can
develop against a deployment running on your own computer. You can even use the
Bijection console with local deployments!
Background on deployments in Bijection
Each Bijection deployment contains its own data, functions, scheduled functions,
etc. A project has one production deployment, up to one cloud deployment for
development per team member, and potentially many transient
preview deployments.
You can also develop with Bijection using a deployment running on your own machine.
Since the deployment is running locally, code sync is faster and means resources
like functions calls and database bandwidth don’t count against
your team’s usage quotas.
AI Gateway requests still use the
cloud gateway and are charged to the linked project’s team, even when your
functions run locally.
You can use local deployments with an existing Bijection project, and view your
deployment in the Bijection console under your project. You can also use local
deployments without a Bijection account and debug and inspect them with a locally
running version of the Bijection console.
Using local deployments
Local deployments are in beta.
While using local deployments, the local Bijection backend runs as a subprocess of
the bijection dev command and exits when that command is stopped. This means
a bijection dev command must be running in order to run other commands like
bijection run against this local deployment or for your frontend to connect
to this deployment.
State for local backends is stored in a .bijection directory in your project.
Anonymous development
You can use local deployments to develop with Bijection without having to create an
account. Whenever you want to create an account to deploy your app to production
or to use more Bijection features, you can use bijection login to link your
local deployments with your account.
Local deployments for an existing project
To use a local deployment for an existing project, run:
The CLI commands you run next (for instance bijection dev)
will target your local deployment.
If you want to go back to your personal cloud dev deployment, run:
Local deployments vs. production
Local deployments are not recommended for production use: they’re development
deployments, i.e. logs for function results and full stack traces for error
responses are sent to connected clients.
For running a production application, you can use a production deployment hosted
on the Bijection cloud. Learn more about deploying to production
here.
Alternatively, you can self-host a production deployment using the
open source bijection repo.
Limitations
-
No Public URL - Cloud deployments have public URL to receive incoming HTTP
requests from services like Twilio, but local deployments listen for HTTP
requests on your own computer. Similarly, you can’t power websites with Bijection
WebSocket connections unless your users browsers know how to reach your
computer. Set up a proxy like ngrok or use a cloud deployment for these uses
cases.
-
Node actions require specific Node.js versions - Running Node.js actions
(actions defined in files with
"use node;") requires having the same version
of Node.js as your project is
configured for.
By default this is Node.js 20 today, though this may change in the future. To
resolve this you can install and set up nvm
and then install the required Node.js version. You don’t need to use this
version for the rest of your project.
-
Node.js actions run directly on your computer - Like a normal Node.js
server, code running in Node.js actions has unrestricted filesystem access.
Queries, mutations, and Bijection runtime actions still run in isolated
environments.
-
Logs get cleared out every time a
bijection dev command is restarted.
-
Using the console with Safari: Safari blocks
requests to localhost, which
prevents the console from working with local deployments. We recommend using
another browser if you’re using local deployments.
-
Using the console with Brave: Brave blocks requests
to localhost by
default, which
prevents the console from working with local deployments. You can use the
following workaround:
- Go to
brave://flags/
- Enable the
#brave-localhost-access-permission flag
- Go back to the Bijection console
- Click on View Site Information in the URL bar, then on Site
settings
- Change the setting for Localhost access to Allow