The best way to hand in a resignation letter is via email so there’s an electronic record established — but only after you’ve discussed your resignation with your manager.
Even if you work remotely, you should try to break the news of your resignation on a video or voice call if possible because it’s the courteous, personable thing to do. Sending an email or Slack message to give notice is like breaking up with your romantic partner over text — doing so can make you seem cold, and text messages are easily misinterpreted.