Define safe.
It's not a best practice. Depending on the scope of your install (e.g. who has access to the system) it may not be a big deal - for example if the only purpose of this machine is to run Nextcloud.
Generally permissions should be 755 on that directory (owner can read, write, enter it) everyone else can only read and enter it. For the nextcloud installer to do its thing the owner of the directory it's being installed in would need to be the web server user - typically nginx. (This could be something else depending on the distro.)
The risk to be mindful of is on a server with multiple (system) users. Having 777 would mean anyone with an account on the server (e.g. users of other websites) could potentially modify/delete the contents of of the website directory. If there are only system accounts + root + your admin account, and if nextcloud is the only thing running the risk is not great, as a compromise won't give access the attacker would not otherwise have. Still it's a bad practice.
The Nextcloud documentation has comments on ownership; it's talking about www-data, that is an ubuntu/apache equivalent of nginx.