Best way to implement a screen recording option in a web app

I’m developing a web app in which I need to provide a feature for screen recording the webpage (possibly a div) and the audio. What is the best way to implement this?

Can you say more about what you mean by this? Do you mean that you are drawing to a p5.js canvas and you also wish to let the user save that animation to a client-side movie file? Or are you trying to allow recordings that then become available server-side…?

What I’m lwishing to do iI want to implement a screen recorder option in my webapp to allow teachers to record the screen and audio from the web app itself without having the difficulty of using third party apps for the same. Not ,just a p5 sketch but webpage as a whole. Is webRTC a good option . I found that it can be used to record a canvas and thee are tools for the conversion of html elements to canvas.

https://html2canvas.hertzen.com

Thanks
Jithin KS