@@ -19,40 +19,62 @@ You install Convex adding the npm dependency to your app:
19
19
npm i convex
20
20
```
21
21
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:
23
23
24
24
``` sh
25
25
npx convex dev
26
26
```
27
27
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.
29
30
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
35
32
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:
38
56
39
57
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.
41
60
1 . A ` convex/ ` folder will be created (if it doesn't exist), where you'll write
42
61
your Convex backend functions.
43
62
44
63
<div className = " center-image" style = { { maxWidth: " 149px" }} >
45
64
![ Convex directory in your app] ( /img/convex-directory.png )
46
65
</div >
47
66
48
- ## Developing your app
67
+ ## Running the dev loop
49
68
50
69
Keep the ` npx convex dev ` command running while you're working on your Convex
51
70
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.
54
76
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:
56
78
57
79
``` typescript title="convex/tasks.ts"
58
80
import { query } from " ./_generated/server" ;
@@ -74,8 +96,9 @@ export const getTaskList = query({
74
96
75
97
When you write and save this code in your editor, several things happen:
76
98
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.
79
102
1 . Your Convex dev deployment analyzes your code and finds all Convex functions.
80
103
In this example, it determines that ` tasks.getTaskList ` is a new public query
81
104
function.
@@ -114,6 +137,8 @@ applied and enforced on your backend.
114
137
The [ Convex dashboard] ( /docs/dashboard/deployments/deployments.md ) will be a
115
138
trusty helper throughout your dev, debug and deploy workflow in Convex.
116
139
140
+ ` npx convex dashboard ` will open a link to the dashboard for your deployment.
141
+
117
142
### Logs
118
143
119
144
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
139
164
140
165
## Deploying your app
141
166
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.
144
173
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.
149
177
150
178
To push your code to your production deployment for your project you run the
151
179
deploy command:
0 commit comments