It’s not ideal but it’s better than nothing. As soon as the water boils, it kills HIV but it takes a while longer to kill other pathogens (things that can cause disease). This is why you have to make sure you boil the needle for at least 20 minutes before you use it.
To stay as safe as possible, it’s best to use new equipment every time you use. If you use new gear each time you do drugs, then there is no risk of a new infection. If you need support finding an agency that provides harm reduction materials like condoms or injection equipment, visit our resource page to find one in your area!