I am using payload for backend only, but the already implemented table is quite good. Is there a way to reuse them?
Do you mean the entire table with all the filters, to use on frontend?
Yes exactly.
This a bit undocumented territory. I was able to replace the data coming from db to query my api instead:
https://github.com/shopnex-ai/shopnex-plugins/blob/main/store-plugin/src/components/plugin-list.tsxIn your case you not need context override but you still need context to subscribe to query string and probably more.
easiest approach is a bit reverse engineering for example:
you can look
https://github.com/payloadcms/payload/blob/70b9cab3932ae3ec02ca3309c3890ea3f1652d65/packages/ui/src/views/List/index.tsx#L37to see each providers you will need and just to rewrite the same as you need:
const { user } = useAuth()
const { getEntityConfig } = useConfig()
const router = useRouter()
const {
data,
defaultLimit: initialLimit,
handlePageChange,
handlePerPageChange,
query,
} = useListQuery()
const { openModal } = useModal()
const { setCollectionSlug, setCurrentActivePath, setOnSuccess } = useBulkUpload()
const { drawerSlug: bulkUploadDrawerSlug } = useBulkUpload()
const collectionConfig = getEntityConfig({ collectionSlug })
const { labels, upload } = collectionConfig
const isUploadCollection = Boolean(upload)
const isBulkUploadEnabled = isUploadCollection && collectionConfig.upload.bulkUpload
const isInDrawer = Boolean(listDrawerSlug)
const { i18n, t } = useTranslation()
const { setStepNav } = useStepNav()
const {
breakpoints: { s: smallBreak },
} = useWindowInfo()Thanks!
Star
Discord
online
Get dedicated engineering support directly from the Payload team.