Open termux and settings -> Developer Options -> Wireless Debugging in split screen like this
Connect to a local wifi network and turn on use wireless debugging button and press allow button
scroll down a bit you'll find option Pair Device with pairing code click it and a dialog opens with a 6 digit ping and ip address:port to connect
In termux use this command to clone and install dependencies
apt update
apt upgrade -y
apt install git -y
git clone https://github.com/SaicharanKandukuri/termux-android12-phantom-fix
cd termux-android12-phantom-fix
bash runme.sh
for prompt like this below
Enter Auth port ( Port show in option enter six digit number):
enter the port number shown in dialog
for promt like this below
Enter Auth pincode:
enter the six digit number ( pairing code )
for promt like this below
Enter debug port:
Enter the port number which appears at ( check below image )
After this script takes care of remaining part
Every Time you login to termux it