v4
Documentation
API
getPropsFromParams()

getPropsFromParams function

💡

This documentation covers an older version of Next Admin. If you are using the latest version (>=5.0.0 and above), please refer to the current documentation.

The following function should be used only for App Router.

getPropsFromParams is a function that returns the props for the NextAdmin component. It accepts one argument which is an object with the following properties:

  • params: the array of route params retrieved from the optional catch-all segment (opens in a new tab)
  • searchParams: the query params retrieved from the page (opens in a new tab)
  • options: the options object
  • schema: the json schema generated by the prisma generate command
  • prisma: your Prisma client instance
  • action: the server action (opens in a new tab) used to submit the form. It should be your own action, that wraps the submitForm action imported from @premieroctet/next-admin/dist/actions.
  • deleteAction: the server action (opens in a new tab) used to delete one or more records in a resource. It is optional, and should be your own action. This action takes 3 parameters: model (the model name) and ids (an array of ids to delete). Next Admin provides a default action for deletion, that you can call in your own action. Check the example app for more details.
  • getMessages: a function with no parameters that returns translation messages. It is used to translate the default messages of the library. See i18n for more details.
  • searchPaginatedResourceAction: the server action (opens in a new tab) used to search for resources in a selector widget. This is mandatory for App Router, and will be ignored on page router. Just like action, it should be your own action that wraps searchPaginatedResource imported from @premieroctet/next-admin/dist/actions.