#how to reduce convex deployment time

1 messages · Page 1 of 1 (latest)

shy sphinx
#

it takes 1.5 minutes sometimes when i run npx convex dev

spice prismBOT
#

Hi @shy sphinx. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Here are a few approaches to reduce Convex deployment time based on the available documentation:

1. Exclude Source Content from Bundles

If your code bundle is large, you can speed up CLI upload times by excluding source code content from the bundle. Add this to your convex.json:

{
  "$schema": "./node_modules/convex/schemas/convex.schema.json",
  "bundler": {
    "includeSourcesContent": false
  }
}

Note: This requires convex NPM package version 1.31.3 or later. Stack traces will still work, but you won't be able to view source code in the dashboard. [bundler options]

2. Use Static Code Generation (Beta)

If TypeScript type inference is slowing down your language server and incremental typechecking, you can enable static code generation in convex.json:

{
  "$schema": "./node_modules/convex/schemas/convex.schema.json",
  "codegen": {
    "staticApi": true,
    "staticDataModel": true
  }
}

This improves autocomplete and incremental typechecking performance, though it comes with tradeoffs like losing jump-to-definition. [static code generation]

3. Use Staged Indexes for Large Tables

If the slowdown happens after adding new indexes to large tables, Convex needs to backfill the index synchronously during deploy. You can use staged indexes to do this asynchronously instead:

export default defineSchema({
  messages: defineTable({
    channel: v.id("channels"),
  }).index("by_channel", { fields: ["channel"], staged: true }),
});
#

Once backfilling is complete (visible in the dashboard), remove the staged: true option to enable the index. [staged indexes]

4. Use Local Deployments

You can develop against a local Convex deployment instead of the cloud, which offers faster code sync and doesn't count against your plan quotas:

npx convex deployment select local
npx convex dev

[local deployments]


The most impactful option depends on your specific bottleneck — large bundles, many indexes, or TypeScript overhead.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: