Google's John Mueller said it is good practice to specify a rel=canonical. John said this is regardless of framework and is espesially true when "you have preferences regarding the URL shown."
He said this on Twitter the other day:
Regardless of the framework it's a good practice to specify a rel=canonical, especially if you have preferences regarding the URL shown.
— 🍌 John 🍌 (@JohnMu) April 1, 2020
A lot of CMS platforms do this by default, but if you have something custom - you can do it as well.
Just don't do it wrong because if you specify the wrong canonical, it can cause serious damage.
Forum discussion at Twitter.