For modern page, I will recommend you to use spfx. SPFx (SharePoint Framework) is a development model introduced by Microsoft for building customizations in SharePoint Online and SharePoint Server 2019. It is specifically designed for SharePoint modern pages and provides a modern and responsive development experience. SPFx enables developers to extend SharePoint modern pages with custom functionality. It allows you to create and deploy client-side web parts, which are reusable components that can be added to modern pages to enhance their capabilities. With SPFx, you can tailor the user experience to meet specific business requirements.
Here is the spfx document
https://learn.microsoft.com/en-us/sharepoint/dev/spfx/sharepoint-framework-overview
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.