docs/1.28/prisma-admin/custom-components-h4jp.mdx
export const meta = { title: "Custom UI components", position: 20, }
Custom components are a powerful extension of the Prisma Admin UI. They allow you to provide a custom UI for displaying your data.
This example shows a custom component for a User record that renders certain fields in a customized way, e.g. the location is displayed as a map and the permissions are rendered as single tags.
Custom components are standard iframe HTML elements which render your data in a custom way. Prisma Admin provides the data for a specific database record to your custom component trough a query string: ${url}?data=${JSON.stringify(data)}. It's possible to have multiple view for single query.
MyUserView)iframe element is being served. Note that Prisma Admin will append the corresponding database record as JSON to the URL as the query string.You can find a basic example of a custom component that simply renders the database record as JSON here:
const qs = require('qs')
const url = require('url')
module.exports = (req, res) => {
const parsed = qs.parse(url.parse(req.url).search, {
ignoreQueryPrefix: true
})
if (parsed.data) {
res.end(JSON.stringify(JSON.parse(parsed.data), null, 2))
} else {
res.end('Please provide data in query string!')
}
}