After talks during the week, a deal was struck on Wednesday.
Swansea manager Alan Sheehan said: "We are happy to have been able to bring in Kaelan ahead of the start of the new season, and he will provide us with additional competition and depth in the defensive area of the pitch.
"He is highly thought of at West Ham, he has been involved in their first-team squad during pre-season, and he is excited about the chance to prove himself at Championship level."
Richard Montague, the Swansea director of football, added: "Kaelan will provide valuable depth for us in an area we had previously identified as needed additional resource this summer.
"He has already had a taste of Premier League football, which underlines how he is viewed by West Ham, and in our discussions with him his appetite to challenge himself has been clear."
