# Convex

[transloadit/convex](https://github.com/transloadit/convex)

`@transloadit/convex` is a Convex component that makes Transloadit feel native. It signs upload options server-side, verifies webhooks, and stores results in Convex so your UI can update in real -time.

## Install

![](/_next/static/media/copy.04p1cju9qekk_.svg?dpl=dpl_CtwzFbHWtqiCy9uvWb9fE7WvfP9N)

```bash
npm i @transloadit/convex @uppy/core @uppy/transloadit

```

## Setup

1. Register the component:

![](/_next/static/media/copy.04p1cju9qekk_.svg?dpl=dpl_CtwzFbHWtqiCy9uvWb9fE7WvfP9N)

```ts
// convex/convex.config.ts
import { defineApp } from 'convex/server'
import transloadit from '@transloadit/convex/convex.config'

const app = defineApp()
app.use(transloadit)

export default app

```

1. Set environment variables:

![](/_next/static/media/copy.04p1cju9qekk_.svg?dpl=dpl_CtwzFbHWtqiCy9uvWb9fE7WvfP9N)

```bash
npx convex env set TRANSLOADIT_KEY <your_auth_key>
npx convex env set TRANSLOADIT_SECRET <your_auth_secret>

```

1. Create actions with `makeTransloaditAPI`:

![](/_next/static/media/copy.04p1cju9qekk_.svg?dpl=dpl_CtwzFbHWtqiCy9uvWb9fE7WvfP9N)

```ts
// convex/transloadit.ts
import { makeTransloaditAPI } from '@transloadit/convex'
import { components } from './_generated/api'

export const { createAssemblyOptions, queueWebhook, listResults } = makeTransloaditAPI(
  components.transloadit,
)

```

## Uppy client

Use Uppy with `assemblyOptions()` from Convex so secrets never reach the browser:

![](/_next/static/media/copy.04p1cju9qekk_.svg?dpl=dpl_CtwzFbHWtqiCy9uvWb9fE7WvfP9N)

```ts
import Uppy from '@uppy/core'
import Transloadit from '@uppy/transloadit'
import { api } from '../convex/_generated/api'

const uppy = new Uppy().use(Transloadit, {
  waitForEncoding: true,
  assemblyOptions: async () => {
    const { assemblyOptions } = await runAction(api.transloadit.createAssemblyOptions, {
      steps: {
        resized: {
          use: ':original',
          robot: '/image/resize',
          width: 800,
        },
      },
    })

    return assemblyOptions
  },
})

```

## Demo app

See the end-to-end wedding gallery demo at[convex-demo.transload.it](https://convex-demo.transload.it/) and the full source in the[GitHub repo](https://github.com/transloadit/convex).
