Depends on the project. My usual go-to is Django, so relatively speaking, while I might have 'written' the authentication model, it depends on thousands of lines of code that the wonderful Django devs already wrote for me.
The right answer to this question, for me at least, is "as little as I can get away with". Sometimes you end up with a bit of technical debt, as a lot of libraries don't quite work how you want or expect, so you end up either forking or rewriting those after launch, but I'm a firm believer in just 'getting to launch' as quickly as possible, and you don't get there by writing your own ORM, caching mechanism, etc.
Sorry to give what has to be a very non-surprising answer.
The right answer to this question, for me at least, is "as little as I can get away with". Sometimes you end up with a bit of technical debt, as a lot of libraries don't quite work how you want or expect, so you end up either forking or rewriting those after launch, but I'm a firm believer in just 'getting to launch' as quickly as possible, and you don't get there by writing your own ORM, caching mechanism, etc.
Sorry to give what has to be a very non-surprising answer.