Many things can cause a boot-looping device. Please give us more history of the device, like whether it was subjected to drops/impacts, water or previous repairs by commenting on this answer.
When it is in a boot-looping mode, this is what I would normally recommend:
- Try a hard reset (Home & Power button for 10 secs)
- Use a genuine Apple Lightning connector
- Use a genuine Apple charging brick and let it charge overnight
- Try to connect it to different computers (mac/pc if possible) with an updated iTunes
- Put the phone in recovery mode (search DFU Mode). Careful, this can reset your data
- Use 3uTools for putting it in and out of Recovery Mode
- Use 3uTools to flash the firmware (you can't downgrade)
- Check the condition of all the flexes (with magnification)
- Disconnect the Front Camera Ribbon from the logic board and reboot your phone
- Disconnect the screen assembly completely and see if iTunes will recognize the phone.
Unfortunately, your problem is intermittent in nature for now. It may get degenerative with time so you may have a logic board issue. If you are uncomfortable doing these steps, consider finding a repair shop to do the troubleshooting. A shop that also does micro-soldering can go deeper if the problem is not modular in nature.