If you have TWRP already:
Have a copy of your device's stock boot image ( boot.img or init_boot.img ) ready on your PC. Method 1: The Sideload Method (Requires Custom Recovery) install magisk with adb
Then in TWRP: → select Magisk.zip → swipe to flash. If you have TWRP already: Have a copy