Discussion: Documentation around singletons/runtime setup (db connections seem most common) #1753
Labels
documentation
Improvements or additions to documentation
Milestone
Is your feature request related to a problem? Please describe.
This is a request for discussion.
One problem brought up in the Discord server pretty often revolves around one-time setup that should happen at startup, where "startup" is either defined as "whenever the server starts" or, for
adapter-static
, "whenever the app runs on the user's browser".In the FAQs, we have a "How do I setup a database?" section. This section documents functionality that is otherwise not documented anywhere, specifically around
hooks.js
. It says "You can execute any one-time setup code in hooks.js and import your database helpers into any endpoint that needs them." I imagine that would look something like this:Describe the solution you'd like
getSession
andhandle
. (It might be nice to also document what this does if you're usingadapter-static
.) If the SvelteKit-approved place to run setup code is inhooks.js
, it should be documented with the documentation abouthooks.js
.Describe alternatives you've considered
How important is this feature to you?
Important enough that I'm willing to make said adjustments in a pull request if I get the go-ahead from a maintainer :)
The text was updated successfully, but these errors were encountered: