Students often get bummed out about their performances, either onstage or just playing for me in their lessons. "But I played it so much better at hooooooome!" I know they did. And the difference between an amateur and a professional is that an amateur's playing suffers slightly with the pressure of performing for another human being, while a professional's playing actually improves.
I like to quantify things that aren't usually measured in order to make certain ideas less mysterious, so bear with me here. Suppose you play a piece extremely well at home - you get an A. Then, when you perform in front of someone else, you become self-conscious. You are imagining yourself from the other person's perspective, which creates a feedback loop wherein you become self-conscious of your self-consciousness ("What if I mess up? What will she think of me then? Whoops, I just messed up - now what does she think?").
As a result of this discomfort, your "grade" drops down to a B. And if you are playing faster than usual, or you're playing on an unfamiliar instrument, or your bench/bow/footrest isn't adjusted perfectly, or you have physical symptoms of nervousness that interfere with your playing, you might drop down to B-minus or C.
One solution to this problem is to practice your piece until it is an A-plus. That is, work until your Comfort Score is a solid nine out of ten. Then track how long it takes you to reach that score from one practice session to another. Five repetitions? Three repetitions? Can you get a Comfort Score of nine on your first try? Once you can do this, your performance will be less likely to suffer in the presence of an audience.
Being more comfortable with your music will not solve the problem entirely. You'll still have to figure out how to deal with the adrenaline flowing through your system. Skilled performers, instead of self-conscious, become self-aware. They use the adrenaline to attain a heightened state of perception, like in that long moment when an outfielder has already anticipated exactly where a pop-up is going and stands waiting patiently for the ball to drop into his glove.
Experienced performers feel the intensity of the audience's presence, but do not second-guess themselves - instead of hoping that they look good, sound good, and don't mess up, they focus on serving the audience well, which makes these musicians authentic and compelling. Doing this sometimes actually leads to weird mess-ups in itself, but not the kind that ruin a performance. Instead, these quirks contribute to the intimacy and immediacy of the moment.
So how do you get to the point where you can do that? Playing at the A-plus, high Comfort Score level definitely helps - mastery allows you to let go of what your hands are doing. Then, you have to let go of what your thoughts are doing. This, too, takes practice.
Experience will contribute significantly to your ability to exhibit grace under pressure. The more you play in front of people, the more effectively you learn to transform anxiety into electricity. Be compassionate with yourself, and expect that in the beginning you won't play as well under stressful conditions. As a result, gradually, you will.