Skip to content

Commit cdfbdbf

Browse files
sshaderConvex, Inc.
authored and
Convex, Inc.
committed
Update docs for using Convex without an account (#35962)
I updated the docs for "Dev workflow" to talk about both developing locally without an account vs. creating an account but tried to keep it short. I also updated the docs on "Local deployments" to cover both anonymous development and using them linked with an account. We could consider updating the "Production" docs with a backlink to "local deployments vs. production" for people who land there first. GitOrigin-RevId: 13f6a8824afa9f51c1a911fbe754afba3844fd8c
1 parent 662ae6d commit cdfbdbf

File tree

2 files changed

+82
-46
lines changed

2 files changed

+82
-46
lines changed

npm-packages/docs/docs/cli/local-deployments-for-dev.mdx

+32-24
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,22 @@ Instead of syncing code to a Convex dev deployment hosted in the cloud, you can
88
develop against a deployment running on your own computer. You can even use the
99
Convex dashboard with local deployments!
1010

11-
## Background on Deployments in Convex
11+
## Background on deployments in Convex
1212

1313
Each Convex deployment contains its own data, functions, scheduled functions,
14-
etc. A project has one production deployment, one cloud deployment for
14+
etc. A project has one production deployment, up to one cloud deployment for
1515
development per team member, and potentially many transient
16-
[preview deployments](/docs/testing.mdx).
16+
[preview deployments](/docs/production/hosting/preview-deployments.mdx).
1717

18-
Running the deployment you're syncing code to during development on your own
19-
machine makes code sync faster and means resources like functions calls and
20-
database bandwidth don't count against
18+
You can also develop with Convex using a deployment running on your own machine.
19+
Since the deployment is running locally, code sync is faster and means resources
20+
like functions calls and database bandwidth don't count against
2121
[the quotas for your Convex plan](https://www.convex.dev/pricing).
2222

23-
Local deployments are not recommended for production use: they're development
24-
deployments, i.e. logs for function results and full stack traces for error
25-
responses are sent to connected clients. For information about self-hosting a
26-
production deployment instead, see the
27-
[convex-backend GitHub repo](https://github.com/get-convex/convex-backend).
23+
You can use local deployments with an existing Convex project, and view your
24+
deployment in the Convex dashboard under your project. You can also use local
25+
deployments without a Convex account and debug and inspect them with a locally
26+
running version of the Convex dashboard.
2827

2928
## Using local deployments
3029

@@ -33,23 +32,19 @@ production deployment instead, see the
3332
While using local deployments, the local Convex backend runs as a subprocess of
3433
the `npx convex dev` command and exits when that command is stopped. This means
3534
a `convex dev` command must be running in order to run other commands like
36-
`npx convex run` against this local deployment.
37-
38-
State for local backends is stored the `~/.convex/convex-backend-state/`
39-
directory.
35+
`npx convex run` against this local deployment or for your frontend to connect
36+
to this deployment.
4037

41-
### Using a Local Deployments for a New Project
38+
State for local backends is stored the `~/.convex/` directory.
4239

43-
When creating a new project you can choose to start out with local development
44-
right away by choosing this option during project creation.
40+
### Anonymous development
4541

46-
In addition to downloading the Convex backend binary and pushing your code to
47-
it, this command updates the `CONVEX_DEPLOYMENT` environment variable in your
48-
`.env.local` file so clients like webapps you're developing and Convex CLI
49-
commands like `npx convex dev` and `npx convex run` know to use the local
50-
deployment.
42+
You can use local deployments to develop with Convex without having to create an
43+
account. Whenever you want to create an account to deploy your app to production
44+
or to use more Convex features, you can use `npx convex login` to link your
45+
local deployments with your account.
5146

52-
### Enabling for an Existing Project
47+
### Local deployments for an existing project
5348

5449
To use a local deployment for an existing project, run:
5550

@@ -62,6 +57,19 @@ You'll also always be given the option for a local deployment if you run
6257
in some situations, for example when connecting to a project for which you
6358
already have a cloud development deployment.
6459

60+
## Local deployments vs. production
61+
62+
Local deployments are not recommended for production use: they're development
63+
deployments, i.e. logs for function results and full stack traces for error
64+
responses are sent to connected clients.
65+
66+
For running a production application, you can use a production deployment hosted
67+
on the Convex cloud. Learn more about deploying to production
68+
[here](/docs/production.mdx).
69+
70+
Alternatively, you can self-host a production deployment using the
71+
[open source convex-backend repo](https://github.com/get-convex/convex-backend).
72+
6573
### Disabling
6674

6775
To stop using local developments for a project, run the following:

npm-packages/docs/docs/understanding/workflow.mdx

+50-22
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,62 @@ You install Convex adding the npm dependency to your app:
1919
npm i convex
2020
```
2121

22-
Then you create your Convex project and start backend dev loop:
22+
Then you create your Convex project and start the backend dev loop:
2323

2424
```sh
2525
npx convex dev
2626
```
2727

28-
The first time you run the `npx convex dev` command you'll be asked to:
28+
The first time you run the `npx convex dev` command you'll be asked whether you
29+
want start developing locally without an account or create an account.
2930

30-
1. Create an account if it doesn't exist
31-
1. This adds your credentials to your `~/.convex/config.json` file. You can
32-
run `npx convex logout` to log your machine out of the account in the
33-
future.
34-
1. Create a new Convex project if it doesn't exist
31+
### Developing without an account
3532

36-
Then Convex will automatically provision a new personal development deployment
37-
for this project for you:
33+
`npx convex dev` will prompt you for the name of your project, and then start
34+
running the open-source Convex backend locally on your machine (this is also
35+
called a "deployment").
36+
37+
The data for your project will be saved in the `~/.convex` directory.
38+
39+
1. The name of your project will get saved to your `.env.local` file so future
40+
runs of `npx convex dev` will know to use this project.
41+
1. A `convex/` folder will be created (if it doesn't exist), where you'll write
42+
your Convex backend functions.
43+
44+
You can run `npx convex login` in the future to create an account and link any
45+
existing projects.
46+
47+
### Developing with an account
48+
49+
`npx convex dev` will prompt you through creating an account if one doesn't
50+
exist, and will add your credentials to `~/.convex/config.json` on your machine.
51+
You can run `npx convex logout` to log you machine out of the account in the
52+
future.
53+
54+
Next, `npx convex dev` will create a new project and provision a new personal
55+
development deployment for this project:
3856

3957
1. Deployment details will automatically be added to your `.env.local` file so
40-
future runs of `npx convex dev` will know what dev deployment to connect to.
58+
future runs of `npx convex dev` will know which dev deployment to connect
59+
to.
4160
1. A `convex/` folder will be created (if it doesn't exist), where you'll write
4261
your Convex backend functions.
4362

4463
<div className="center-image" style={{ maxWidth: "149px" }}>
4564
![Convex directory in your app](/img/convex-directory.png)
4665
</div>
4766

48-
## Developing your app
67+
## Running the dev loop
4968

5069
Keep the `npx convex dev` command running while you're working on your Convex
5170
app. This continuously pushes backend code you write in the `convex/` folder to
52-
your dev deployment. It also keeps the necessary TypeScript types up-to-date as
53-
you write your backend code.
71+
your deployment. It also keeps the necessary TypeScript types up-to-date as you
72+
write your backend code.
73+
74+
When you're developing with a locally running deployment, `npx convex dev` is
75+
also responsible for running your deployment.
5476

55-
You can then add new new server functions to your Convex backend:
77+
You can then add new server functions to your Convex backend:
5678

5779
```typescript title="convex/tasks.ts"
5880
import { query } from "./_generated/server";
@@ -74,8 +96,9 @@ export const getTaskList = query({
7496

7597
When you write and save this code in your editor, several things happen:
7698

77-
1. The `npx convex dev` command uploads the contents of your `convex/` directory
78-
to your dev deployment.
99+
1. The `npx convex dev` command typechecks your code and updates the
100+
`convex/_generated` directory.
101+
1. The contents of your `convex/` directory get uploaded to your dev deployment.
79102
1. Your Convex dev deployment analyzes your code and finds all Convex functions.
80103
In this example, it determines that `tasks.getTaskList` is a new public query
81104
function.
@@ -114,6 +137,8 @@ applied and enforced on your backend.
114137
The [Convex dashboard](/docs/dashboard/deployments/deployments.md) will be a
115138
trusty helper throughout your dev, debug and deploy workflow in Convex.
116139

140+
`npx convex dashboard` will open a link to the dashboard for your deployment.
141+
117142
### Logs
118143

119144
Since Convex functions are TypeScript functions you can always use the standard
@@ -139,13 +164,16 @@ There is a lot more to to the dashboard. Be sure to click around or
139164

140165
## Deploying your app
141166

142-
So far you've been working on your app against your personal dev deployment for
143-
the current project.
167+
So far you've been working on your app against your personal dev deployment.
168+
169+
All Convex projects have one production deployment running in the cloud. It has
170+
separate data and has a separate push process from personal dev deployments,
171+
which allows you and your teammates to work on new features using personal dev
172+
deployments without disrupting your app running in production.
144173

145-
All projects have one production deployment. It has separate data and has a
146-
separate push process from personal dev deployments, which allows you and your
147-
teammates to work on new features using personal dev deployments without
148-
disrupting your app running in production.
174+
If you have not created a Convex account yet, you will need to do so with
175+
`npx convex login`. This will automatically link any projects you've started
176+
with your new account, and enable using your production deployment.
149177

150178
To push your code to your production deployment for your project you run the
151179
deploy command:

0 commit comments

Comments
 (0)