nostr is (mostly) client side, so you'd instantiate it always on the client side (you can't really instantiate something like NDK on the server and "pass" it to the end client)
It might make sense to have a look at the work nostr:npub18c556t7n8xa3df2q82rwxejfglw5przds7sqvefylzjh8tjne28qld0we7 is doing packaging NDK in a ready-made skeleton or have a look at production code in one of the multiple real-world reference implementations using NDK 😉
https://github.com/nostr-dev-kit/ndk/blob/master/REFERENCES.md