There are a number of ways to troubleshoot an iPhone
that keeps disconnecting from WiFi.
Before anything, rule out these simple fixes.
Check if your iPhone is in airplane mode.
Make sure that WiFi is turned on.
Check that you're connected to the right WiFi network
with the right password.
Install any available updates for iOS.
If your phone isn't connecting to WiFi properly,
first try restarting your phone.
And if that doesn't work, try restarting your router.
If your phone is not connecting to the right network,
tap on the network's name,
and then select "Forget This Network,"
then rejoin the correct network with its password.
If this doesn't work,
you can reset your iPhone's network settings
for a fresh start.
In the settings app, go to "General."
Then scroll down to "Transfer or Reset iPhone."
In the next tab, tap "Reset."
Then select "Reset Network Settings."
Enter your iPhone's passcode to confirm the reset.
Your iPhone will restart,
but you won't lose any data or apps.
If you've done all this
and your iPhone still can't keep a stable connection,
it might be time to contact
either your internet service provider or Apple support.