title: Where is the best place to initialise a database in a Svelte app
body: <p>So I have a Svelte app that uses data from a better-sqlite3 database. The app pulls data from the database and stores it in a Svelte store. The app also initialises the database and creates tables if they don't exist already. I'm struggling to work out the best place to do the DB init. Currently, it's at the start of my Store.js because that's where it works but it feels wrong and I'm wondering if I might not be making trouble for myself.</p>
  <p>By way of illustration below is a link to a REPL that approximates what's going on without the database stuff.</p>
  <p><a href="https://svelte.dev/repl/54e5787a37ff47bb9f72476dab67d3b1?version=3.35.0" rel="nofollow noreferrer">https://svelte.dev/repl/54e5787a37ff47bb9f72476dab67d3b1?version=3.35.0</a></p>