I am working with a web application using Node.js and Express, and I display a video with some subtitles generated dynamically. I was wondering if there was a way to integrate this subtitles in the video so that the user could download this new video.
Probably not.
As you said, the subtitles are dynamic and are not 'baked' into the video. You'd have to re-render the video with the subtitles in order to ship them together.
A solution might be to zip the video alongside with a subtitle file (.srt) so that the user can view them with a video player like VLC. This also gives you the option to add multiple languages for example.
You'd need to transcode/transmux the video in ffmpeg or some other tool. Ideally you'd create your subtitles in SRT or webvtt format, then add them to the video file: ffmpeg -i video.mp4 -i subtitles.srt -c copy video_with_subtitles.mp4. Or you could "burn" them into the video, but that's usually not the preferred experience.