Safari doesn't support that API whatsoever so a third party JS library is really your only option. The landscape of open source barcode detection libraries is bleak at the moment.
It does since iOS 17. For now you’ll have to enable it manually through Settings > Safari > Advanced > Feature Flags > Shape Detection API but I expect it to be enabled by default soon.