This document outlines the plan for completing the migration from tRPC to Convex.
- Type Safety is Key: The migration has highlighted the importance of strong typing. Using
v.unionin the Convex schema for enum-like fields andas constfor default value arrays has been crucial for avoiding runtime errors. idvs_id: Convex uses_idfor document IDs, while the legacy code and some UI components expectid. It's important to map these correctly when passing data to components.orgSlugvsorgId: The URL parameter is theorgSlug, not the database_id. I've started renaming the route parameter toorgSlugto avoid confusion. This should be done consistently across the app.- Convex Hooks:
useQueryreturnsundefinedwhile loading, not anisLoadingboolean.useMutationdoes not return anisPendingproperty, so loading states must be handled manually withuseState. - Server-Side Logic: All server-side data fetching and permission checks in page and layout components must be moved into client components using Convex hooks.
The following files still use tRPC and need to be migrated to Convex:
src/components/issues/issues-table.tsxsrc/components/issues/issue-selectors.tsxsrc/app/api/trpc/[trpc]/route.tssrc/components/projects/project-members.tsxsrc/components/organization/states-management-dialog.tsxsrc/components/organization/states-management-popover.tsxsrc/components/organization/custom-roles-manager.tsxsrc/components/organization/priorities-management-dialog.tsxsrc/app/[orgSlug]/(main)/teams/[teamKey]/page.tsx
- Refactor Remaining Components: Go through the list above and refactor each component to use Convex hooks instead of tRPC.
- Implement Missing Convex Functions: As new components are refactored, implement any missing Convex queries and mutations that they depend on.
- Complete
orgSlugRenaming: Ensure that all references to the organization URL parameter are namedorgSlugfor clarity. - Remove Legacy Code: Once all components are refactored, remove the
trpcdirectory and any other unused legacy code. - Remove
[trpc]API Route: Delete thesrc/app/api/trpc/[trpc]/route.tsfile. - Comprehensive Testing: Thoroughly test the application to ensure that all features work as expected with the new Convex backend.
- Do not use
any: Avoid usinganyas a type. If there is a type mismatch, fix the root cause by updating the schema, the data transformation, or the component props. [[memory:4475326]] - Do not change
paramsprop type: Theparamsprop in page components must be aPromise. Do not change it. - Check Convex Docs: When unsure about how a Convex hook works, consult the documentation before making assumptions.
- Handle loading states correctly: Remember that
useQueryreturnsundefinedwhile loading and thatuseMutationdoes not provide anisPendingstate. - Be careful with IDs: Always ensure that you are using the correct ID (
_idvsid) and that you are casting string IDs to theIdtype when calling mutations.