Convex Component
@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
npm i @transloadit/convex @uppy/core @uppy/transloadit
Setup
- Register the component:
// 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
- Set environment variables:
npx convex env set TRANSLOADIT_KEY <your_auth_key>
npx convex env set TRANSLOADIT_SECRET <your_auth_secret>
- Create actions with
makeTransloaditAPI:
// 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:
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 and the full source in the GitHub repo.