This really depends on what exactly already exists and how much capital (money and development capital) you have available.
If you can do it better, then great. If they are already well ahead on features and you can't find the capital to come to feature parity and beyond, or to do something radically different, then you may have to cut your losses and pivot.
This really is likely a failure to do full research before starting the project, unless the competitor launched during your development.
I've seen this happen far too many times, and not only with software. This is a common failure in small business. The smaller you are and the less resources you have, the more critical this type of research, before starting a project, is. Large household names can afford throwing away capital. Small business can't.
If you have to pivot, let it be a lesson and do way more research next time.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.