89 |
90 |
104 | >
105 | );
106 | }
107 |
108 | export default App;
109 |
--------------------------------------------------------------------------------
/src/assets/react.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/convex/_generated/server.d.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * Generated utilities for implementing server-side Convex query and mutation functions.
4 | *
5 | * THIS CODE IS AUTOMATICALLY GENERATED.
6 | *
7 | * Generated by convex@1.9.0.
8 | * To regenerate, run `npx convex dev`.
9 | * @module
10 | */
11 |
12 | import {
13 | ActionBuilder,
14 | HttpActionBuilder,
15 | MutationBuilder,
16 | QueryBuilder,
17 | GenericActionCtx,
18 | GenericMutationCtx,
19 | GenericQueryCtx,
20 | GenericDatabaseReader,
21 | GenericDatabaseWriter,
22 | } from "convex/server";
23 | import type { DataModel } from "./dataModel.js";
24 |
25 | /**
26 | * Define a query in this Convex app's public API.
27 | *
28 | * This function will be allowed to read your Convex database and will be accessible from the client.
29 | *
30 | * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
31 | * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
32 | */
33 | export declare const query: QueryBuilder;
34 |
35 | /**
36 | * Define a query that is only accessible from other Convex functions (but not from the client).
37 | *
38 | * This function will be allowed to read from your Convex database. It will not be accessible from the client.
39 | *
40 | * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
41 | * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
42 | */
43 | export declare const internalQuery: QueryBuilder;
44 |
45 | /**
46 | * Define a mutation in this Convex app's public API.
47 | *
48 | * This function will be allowed to modify your Convex database and will be accessible from the client.
49 | *
50 | * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
51 | * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
52 | */
53 | export declare const mutation: MutationBuilder;
54 |
55 | /**
56 | * Define a mutation that is only accessible from other Convex functions (but not from the client).
57 | *
58 | * This function will be allowed to modify your Convex database. It will not be accessible from the client.
59 | *
60 | * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
61 | * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
62 | */
63 | export declare const internalMutation: MutationBuilder;
64 |
65 | /**
66 | * Define an action in this Convex app's public API.
67 | *
68 | * An action is a function which can execute any JavaScript code, including non-deterministic
69 | * code and code with side-effects, like calling third-party services.
70 | * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
71 | * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
72 | *
73 | * @param func - The action. It receives an {@link ActionCtx} as its first argument.
74 | * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
75 | */
76 | export declare const action: ActionBuilder;
77 |
78 | /**
79 | * Define an action that is only accessible from other Convex functions (but not from the client).
80 | *
81 | * @param func - The function. It receives an {@link ActionCtx} as its first argument.
82 | * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
83 | */
84 | export declare const internalAction: ActionBuilder;
85 |
86 | /**
87 | * Define an HTTP action.
88 | *
89 | * This function will be used to respond to HTTP requests received by a Convex
90 | * deployment if the requests matches the path and method where this action
91 | * is routed. Be sure to route your action in `convex/http.js`.
92 | *
93 | * @param func - The function. It receives an {@link ActionCtx} as its first argument.
94 | * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
95 | */
96 | export declare const httpAction: HttpActionBuilder;
97 |
98 | /**
99 | * A set of services for use within Convex query functions.
100 | *
101 | * The query context is passed as the first argument to any Convex query
102 | * function run on the server.
103 | *
104 | * This differs from the {@link MutationCtx} because all of the services are
105 | * read-only.
106 | */
107 | export type QueryCtx = GenericQueryCtx;
108 |
109 | /**
110 | * A set of services for use within Convex mutation functions.
111 | *
112 | * The mutation context is passed as the first argument to any Convex mutation
113 | * function run on the server.
114 | */
115 | export type MutationCtx = GenericMutationCtx;
116 |
117 | /**
118 | * A set of services for use within Convex action functions.
119 | *
120 | * The action context is passed as the first argument to any Convex action
121 | * function run on the server.
122 | */
123 | export type ActionCtx = GenericActionCtx;
124 |
125 | /**
126 | * An interface to read from the database within Convex query functions.
127 | *
128 | * The two entry points are {@link DatabaseReader.get}, which fetches a single
129 | * document by its {@link Id}, or {@link DatabaseReader.query}, which starts
130 | * building a query.
131 | */
132 | export type DatabaseReader = GenericDatabaseReader;
133 |
134 | /**
135 | * An interface to read from and write to the database within Convex mutation
136 | * functions.
137 | *
138 | * Convex guarantees that all writes within a single mutation are
139 | * executed atomically, so you never have to worry about partial writes leaving
140 | * your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
141 | * for the guarantees Convex provides your functions.
142 | */
143 | export type DatabaseWriter = GenericDatabaseWriter;
144 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright 2024 Convex, Inc.
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Convex Hack Pack
2 |
3 | Hello, hackers! Welcome to [Convex](https://convex.dev), a full-featured backend
4 | platform you can use to rapidly prototype any hackathon app you can think of!
5 |
6 | ## So you want to build an app, ASAP
7 |
8 | If you're building an app for a hackathon, there's no time to waste! Convex is
9 | the perfect partner for hackers on a deadline because:
10 |
11 | - you get a cloud-hosted database & serverless backend for free
12 | - your frontend clients get automatic, realtime data updates
13 | - you can flexibly change your database schema as your product evolves
14 | - you get file storage, text- and vector-based search, cron jobs, and lots more
15 | out of the box
16 |
17 | Whatever your idea is, Convex can help you make it happen!
18 |
19 | ## What is this hack pack?
20 |
21 | This repository is your starting point for getting hacking with Convex. It
22 | includes:
23 |
24 | - A simple Convex demo app to demonstrate the basics
25 | - Hands-on exercises to get you started (below)
26 | - Lots of further reading links & resources to keep you going (below)
27 |
28 | ## Before you begin
29 |
30 | - Sign up for a free Convex account at [convex.dev](https://convex.dev)
31 | - [highly recommended] Sign up for a [Github](https://github.com) account if you
32 | don't have one already
33 | - Get your development environment set up:
34 | - Make sure you have [git](https://github.com/git-guides/install-git)
35 | installed, or install it if needed
36 | - Install/update [Node.js](https://nodejs.org/en/download) (which includes
37 | [npm](https://www.npmjs.com/)) to the latest LTS version
38 | - [optional] Read up on the technologies we'll be using:
39 | - [JavaScript](https://developer.mozilla.org/en-US/docs/Learn/JavaScript) and
40 | [TypeScript](https://www.typescriptlang.org/) programming languages
41 | - [React](https://react.dev/) JS/TS frontend framework
42 | - [Vite](https://vitejs.dev/) JS/TS build & development tool
43 | - and of course, [Convex](https://docs.convex.dev)!
44 |
45 | ## Install the hack pack
46 |
47 | - Download a local copy of this repository from Github using `git`:
48 |
49 | ```
50 | git clone https://github.com/get-convex/convex-hack-pack.git
51 | ```
52 |
53 | (Note: if you prefer, you can also clone the repo with the
54 | [Github CLI](https://cli.github.com/) or
55 | [download a ZIP file](https://github.com/get-convex/convex-hack-pack/archive/refs/heads/main.zip)
56 | of the contents)
57 |
58 | - Install the project dependencies:
59 |
60 | ```
61 | cd convex-hack-pack
62 | npm install
63 | ```
64 |
65 | - Run the following command, then follow the prompts to configure a new project
66 | in your Convex account and start the development server for the demo site:
67 |
68 | ```
69 | npm run dev
70 | ```
71 |
72 | - You should see the demo app automatically open in your web browser (if not,
73 | navigate to [localhost:5173](http://localhost:5173))
74 | - In the demo app, type in a new app idea and click "Save", and/or click the
75 | "Generate a random app idea" button, and you should see the ideas appear!
76 |
77 | You may have noticed that "Include random ideas" checkbox in the demo app
78 | doesn't work! Don't worry, we're going to fix it. But before we do, let's take a
79 | closer look at our data in the Convex dashboard.
80 |
81 | ---
82 |
83 | # Exercises
84 |
85 | ## Exercise 1: Update your data
86 |
87 | - In the browser, navigate to the `convex-hack-pack` project in your
88 | [Convex dashboard](https://dashboard.convex.dev) (if it didn't open
89 | automatically) - you'll be taken to the 'Data' tab where you should see the
90 | `ideas` table and any documents inside it
91 | - Edit data:
92 | - Double-click in the 'idea' field of any document and edit the text
93 | - Back in your demo app, you'll see the text has automatically updated!
94 | - Add new data:
95 | - In the dashboard `ideas` table, click the "Add documents" button on the top
96 | right
97 | - In the document editor that opens, type a new app idea to fill out the
98 | `idea` property (e.g. `"A brainstorming app for developers"` - in quotes,
99 | because it's a string value)
100 | - Click "Save" to save the new document
101 | - In both the dashboard and the demo app, you should now see your new idea!
102 |
103 | But we're not done yet - that "Include random ideas" checkbox in our app still
104 | doesn't work! Let's fix that.
105 |
106 | ## Exercise 2: Update your backend
107 |
108 | - Update your `listIdeas` function:
109 |
110 | - In your code editor, open `convex/myFunctions.ts`
111 | - In the `listIdeas` query function, add an additional argument named
112 | `includeRandom` to the `args` object, whose value is a boolean
113 | (`v.boolean()`). The `args` object should now look like this:
114 |
115 | ```js
116 | args: {
117 | includeRandom: v.boolean()
118 | },
119 | ```
120 |
121 | - In the `handler` function, add an `if` conditional based on the value of
122 | `args.includeRandom`: if true, return the same query results as before, but
123 | if false, filter the data to only return documents where the `random` field
124 | is _not_ equal to `true`, like so:
125 |
126 | ```js
127 | handler: async (ctx, args) => {
128 | if (args.includeRandom) {
129 | return await ctx.db.query("ideas").collect(); // Returns all documents in the 'ideas' table
130 | } else {
131 | return await ctx.db
132 | .query("ideas")
133 | .filter((q) => q.neq(q.field("random"), true)) // Only returns documents whose 'random' field is not equal to `true`
134 | .collect();
135 | }
136 | },
137 | ```
138 |
139 | - Save the `myFunctions.ts` file, and in the terminal where you have
140 | `npm run dev` running, you should see a log line that says "Convex functions
141 | ready!" (this means your new function code has been successfully deployed)
142 |
143 | - Test out your updated function
144 | - Go to your [Convex dashboard](https://dashboard.convex.dev), navigate to the
145 | "Functions" tab (`>`) and open `myFunctions:listIdeas`. You should now see
146 | the new version of your code there!
147 | - Click the "Run function" button to try out your new function in the
148 | dashboard
149 | - In the "Arguments" panel, edit the value of `includeRandom` and verify that
150 | you see the correct results in the "Query outcome" panel!
151 |
152 | Great, we've confirmed in the Convex dashboard that our backend change was
153 | successful!
154 |
155 | But now when visiting [localhost:5173](http://localhost:5173) you'll see a whole
156 | lot of nothing. That's because our backend function change broke the frontend
157 | code that invokes that function! Let's fix it and get our ideas back.
158 |
159 | ## Exercise 3: Update your frontend
160 |
161 | - In your code editor, open `src/App.tsx`
162 | - In the `App` function, find the line near the top where `ideas` is defined
163 | using the `useQuery()` hook to call the `api.myFunctions.listIdeas` query
164 | function
165 | - The `useQuery` hook can take an optional second argument, an `args` object
166 | that matches the `args` validator of the given query function. Update the call
167 | to `useQuery()` to pass `{ includeRandom }` as the second argument, like so:
168 | ```js
169 | const ideas = useQuery(api.myFunctions.listIdeas, { includeRandom });
170 | ```
171 | - Now, not only are the ideas displaying properly, but when you (un)check the
172 | "Include random ideas" checkbox you should see the results update accordingly!
173 |
174 | ## Bonus: Challenge Exercises
175 |
176 | If you've got extra time, try your hand at implementing some new features for
177 | the app!
178 |
179 | ### Challenge 1: Delete idea button
180 |
181 | Currently, there is no way for a user to delete an idea from the page. Your
182 | challenge is to add a button that fixes that!
183 |
184 | Hints:
185 |
186 | - In `convex/myFunctions.ts` you'll need to create a new mutation function
187 | `deleteIdea`, which
188 | [deletes a document](https://docs.convex.dev/database/writing-data#deleting-documents)
189 | from the `ideas` table using its
190 | [Convex document ID](https://docs.convex.dev/database/document-ids)
191 | - In `src/App.tsx`, you'll need the `useMutation` hook to invoke your new
192 | `deleteIdea` function as needed from the frontend
193 | - In `src/App.tsx`, you can add a new button using the `Button` component (see
194 | the "Generate a random app idea" button for an example)
195 |
196 | ### Challenge 2: Prevent duplicates
197 |
198 | At the moment, the app doesn't prevent you from adding the same idea twice (try
199 | it!), so we might save duplicate ideas to the database. Your challenge is to fix
200 | that by making sure that we check for duplicates before saving a new idea!
201 |
202 | Hints:
203 |
204 | - In `convex/myFunctions.ts`, you can modify the `saveIdea` function to check
205 | for duplicates by performing a
206 | [filtered query](https://docs.convex.dev/database/reading-data#equality-conditions)
207 | before inserting the new document. If the query finds any documents whose
208 | `idea` field exactly matches the new idea, do not insert the new document
209 | - To let users know what's happening, you probably want to treat the
210 | did-not-save-duplicate case as an
211 | [application error](https://docs.convex.dev/functions/error-handling/application-errors)
212 | and handle it in the frontend accordingly
213 |
214 | ### Challenge 3: Pagination
215 |
216 | As the list of ideas grows, the page will get very long! Improve performance by
217 | paginating the list of ideas to show only 20 ideas at a time, and let users page
218 | through the rest of the results.
219 |
220 | Hints:
221 |
222 | - In `convex/myFunctions.ts`, you can change the `listIdeas` query function to a
223 | [paginated query](https://docs.convex.dev/database/pagination) function by
224 | accepting a `paginationOpts` argument
225 | - In `src/App.tsx` you'll also need to update the frontend code to use the
226 | [`usePaginatedQuery` hook](https://docs.convex.dev/database/pagination#paginating-within-react-components)
227 | instead of the `useQuery` hook when invoking the `listIdeas` function
228 | - Don't forget to add some buttons or another way for users to access the
229 | next/previous page(s)!
230 |
231 | ---
232 |
233 | # Next steps
234 |
235 | Now that you've grokked the basics, you're ready to get building!
236 |
237 | ## Create a new app from a starter template
238 |
239 | You can quickly spin up a new Convex app with the command:
240 |
241 | ```
242 | npm create convex@latest
243 | ```
244 |
245 | This will install the
246 | [`create-convex`](https://www.npmjs.com/package/create-convex) bootstrapper
247 | tool, which will then ask you a series of questions to configure your starter
248 | code. Walk through the prompts and the instructions that follow.
249 |
250 | ## Explore the Convex platform and everything it can do
251 |
252 | Convex offers lots of functionality, so you can pick and choose the parts of the
253 | platform you need to build the app of your dreams!
254 |
255 | Here are some resources to help get you building:
256 |
257 | - For a more in-depth structured intro to Convex, take the
258 | [guided tour](https://docs.convex.dev/get-started)
259 | - The [Convex docs](https://docs.convex.dev/home) are a comprehensive reference
260 | of platform features and how to use them
261 | - [Stack](https://stack.convex.dev/) is Convex's developer learning portal, with
262 | tons of articles & videos on best practices and how-tos
263 | - You can ask questions, get help, and share your Convex projects in the
264 | community [Discord](https://www.convex.dev/community)
265 | - [Convex Search](https://search.convex.dev/) lets you search across all of the
266 | above to find the info you need!
267 | - The [template gallery](https://www.convex.dev/templates) has tons of sample
268 | apps for different tech stacks and use cases
269 |
270 | And in case you want to jump right in to implementing common app features, here
271 | are some resouces on how to:
272 |
273 | - Model [relationships](https://docs.convex.dev/database/document-ids) between
274 | documents
275 | - [Authenticate & manage users](https://docs.convex.dev/auth)
276 | - [Paginate](https://docs.convex.dev/database/pagination) query results
277 | - Retrieve documents with [text](https://docs.convex.dev/text-search) or
278 | [vector](https://docs.convex.dev/vector-search) search
279 | - [Schedule](https://docs.convex.dev/scheduling) function runs
280 | - [Store and manage files](https://docs.convex.dev/file-storage)
281 | - Build [AI apps](https://stack.convex.dev/tag/AI)
282 |
283 | ---
284 |
285 | # What is Convex?
286 |
287 | 
288 |
289 | [Convex](https://convex.dev) is a hosted backend platform with a built-in
290 | database that lets you write your
291 | [database schema](https://docs.convex.dev/database/schemas) and
292 | [server functions](https://docs.convex.dev/functions) in
293 | [TypeScript](https://docs.convex.dev/typescript). Server-side database
294 | [queries](https://docs.convex.dev/functions/query-functions) automatically
295 | [cache](https://docs.convex.dev/functions/query-functions#caching--reactivity)
296 | and [subscribe](https://docs.convex.dev/client/react#reactivity) to data,
297 | powering a
298 | [realtime `useQuery` hook](https://docs.convex.dev/client/react#fetching-data)
299 | in our [React client](https://docs.convex.dev/client/react). There are also
300 | [Python](https://docs.convex.dev/client/python),
301 | [Rust](https://docs.convex.dev/client/rust),
302 | [ReactNative](https://docs.convex.dev/client/react-native), and
303 | [Node](https://docs.convex.dev/client/javascript) clients, as well as a
304 | straightforward
305 | [HTTP API](https://github.com/get-convex/convex-js/blob/main/src/browser/http_client.ts#L40).
306 |
307 | The database supports
308 | [NoSQL-style documents](https://docs.convex.dev/database/document-storage) with
309 | [relationships](https://docs.convex.dev/database/document-ids),
310 | [custom indexes](https://docs.convex.dev/database/indexes/) (including on fields
311 | in nested objects) and [vector search](https://docs.convex.dev/vector-search).
312 |
313 | The [`query`](https://docs.convex.dev/functions/query-functions) and
314 | [`mutation`](https://docs.convex.dev/functions/mutation-functions) server
315 | functions have transactional, low latency access to the database and leverage
316 | our [`v8` runtime](https://docs.convex.dev/functions/runtimes) with
317 | [determinism guardrails](https://docs.convex.dev/functions/runtimes#using-randomness-and-time-in-queries-and-mutations)
318 | to provide the strongest ACID guarantees on the market: immediate consistency,
319 | serializable isolation, and automatic conflict resolution via
320 | [optimistic multi-version concurrency control](https://docs.convex.dev/database/advanced/occ)
321 | (OCC / MVCC).
322 |
323 | The [`action` server functions](https://docs.convex.dev/functions/actions) have
324 | access to external APIs and enable other side-effects and non-determinism in
325 | either our [optimized `v8` runtime](https://docs.convex.dev/functions/runtimes)
326 | or a more
327 | [flexible `node` runtime](https://docs.convex.dev/functions/runtimes#nodejs-runtime).
328 |
329 | Functions can run in the background via
330 | [scheduling](https://docs.convex.dev/scheduling/scheduled-functions) and
331 | [cron jobs](https://docs.convex.dev/scheduling/cron-jobs).
332 |
333 | Development is cloud-first, with
334 | [hot reloads for server function](https://docs.convex.dev/cli#run-the-convex-dev-server)
335 | editing via the [CLI](https://docs.convex.dev/cli). There is a
336 | [dashbord UI](https://docs.convex.dev/dashboard) to
337 | [browse and edit data](https://docs.convex.dev/dashboard/deployments/data),
338 | [edit environment variables](https://docs.convex.dev/production/environment-variables),
339 | [view logs](https://docs.convex.dev/dashboard/deployments/logs),
340 | [run server functions](https://docs.convex.dev/dashboard/deployments/functions),
341 | and more.
342 |
343 | There are built-in features for
344 | [reactive pagination](https://docs.convex.dev/database/pagination),
345 | [file storage](https://docs.convex.dev/file-storage),
346 | [reactive search](https://docs.convex.dev/text-search),
347 | [https endpoints](https://docs.convex.dev/functions/http-actions) (for
348 | webhooks),
349 | [streaming import/export](https://docs.convex.dev/database/import-export/), and
350 | [runtime data validation](https://docs.convex.dev/database/schemas#validators)
351 | for [function arguments](https://docs.convex.dev/functions/args-validation) and
352 | [database data](https://docs.convex.dev/database/schemas#schema-validation).
353 |
354 | Everything scales automatically, and it’s
355 | [free to start](https://www.convex.dev/plans).
356 |
--------------------------------------------------------------------------------