Packages like nginx and openssh ship a ufw profile, so I do not have to remember which ports they use.
sudo ufw app list
sudo ufw app info 'Nginx Full'
sudo ufw allow 'Nginx Full'
Profiles live as small files in /etc/ufw/applications.d. app info shows the ports and protocols behind a name, so you know what you open. Names with spaces need quotes. Rules made from a profile show the profile name in ufw status. If you change a profile file, run sudo ufw app update PROFILE to refresh the rules that were built from it.
Further reading: ufw manual page