If these are spinning HDDs then there is a chance of recovery (maybe incomplete, maybe data loss). If they are SSDs, then the chances of data recovery are very small.
DiskDrill is a highly-recommended utility for data recovery:
https://www.cleverfiles.com/lp/data-recovery-software.html
Taking a step back, the usual advice would be to just restore from your Time Machine backup. If you don't have one, then you have learned a lesson the hard way. There are two types of drives – those that have failed and those that have not failed yet. Besides such catastrophic occurrences, there are other situations where a backup is very helpful – if you overwrite or delete a file, for example. Apple provides an excellent utility that’s already installed on your Mac, Time Machine.
Back up your Mac with Time Machine - Apple Support
Time Machine allows recovery of individual files and folders from prior backups. If you use the default setting of hourly backups, then you will have the option to revert hourly for the past 24 hours, then daily for the past month and weekly beyond that, to recover changed files or folders, or your whole system. That can protect you not only from a drive failure, but for example from loss/damage/theft. You can replace a Mac, and restore the old data to the new Mac from the Time Machine backup.
It’s recommended to back up to an external drive that is 2-3x the size of your internal storage. External storage is relatively inexpensive, a 1 TB SSD or a 2-4 TB HDD can be purchased for <$200 (prices have gone up significantly in recent months, unfortunately). Consider that one backup may not be enough, a commonly recommended strategy is 3-2-1 where you have three copies of your data, two of which are backups and one of which is stored offsite.
If you have not started using Time Machine to back up your Mac, now is the Time (pun intended).