Typically you would use a hidden div element that has the same styles applied as the textarea, plus a bid of extra bottom padding. Then while typing into the Textarea you will copy the text into the div element and read the div element's height. Then you can set the height to the Textarea. If you want to avoid setting the height yourself to the Textarea you could use CSS to do so:
<div> //wrapper div that has position:relative
<div></div> // hidden div that has at least: position:relative; padding-bottom:20px; visibility:hidden;
<textarea /> //Textarea that has position:absolute; top:0px; left:0px;right:0px;bottom:0px;
</div>
This should let the textarea always fit the size of the wrapper div. The size of the wrapper div is defined by the text you copy from the textarea into the hidden div (because of position:relative and position:absolute)
Works pretty well for me. For best results you just have to make sure that the hidden div would show the text exactly the same as the textarea.
-- J.