Sounds like The Boy Who Reversed Himself, by William Sleator.
A high school girl named Laura grows suspicious when a report of hers appears in mirror writing, and Omar, the weird boy next door, makes it go back to normal. Furthermore, he seems to be parting his hair on a different side than usual. He first refuses to explain what's going on, but after she repeatedly coaxes him, he reveals that he has access to the fourth dimension, where he accidentally "reversed" himself. He eventually allows her to visit it under his supervision, but he warns her that it is extremely dangerous and that he is violating some agreement by letting her in on the secret. She tries to use her access to the higher dimension to impress Pete, a popular boy she wants to go to the school dance with, but after she seems to disappear into thin air and unlock a door from the other side, Pete realizes something funny is going on, and she feels pressured to show him the truth, without Omar's knowledge. When she brings Pete into four-space, they lose their way and end up as the captives of four-dimensional creatures. Unfortunately, she determines that escaping might threaten the very existence of her own world by making the powerful 4-D creatures aware of it. With Omar's help, she finds a safe way out and learns the truth about how he came to know about other dimensions.