Hey,
If I have two .wit files, how do I import types/interfaces/records from one .wit file into the other? Say one is:
// logger.wit
package techaro:logger;
interface sink {
debug: func(msg: string);
info: func(msg: string);
warn: func(msg: string);
error: func(msg: string);
}
world logger {
import sink;
}
How do I use the techaro:logger/sink interface in another .wit file?
You might want to read over this and this to help answer this?
Also, note that you likely want to get the WIT that you're trying to share out into a properly "shared" place.
You don't have to go as far as actually publishing it, but you may benefit from separating the interface and the world that represents the usage of that interface
As for examples, I wish I could point to an example repo that shows this simply (the component model book is close, but we need to make changes to the WIT fetching instructions!)
But for now, the absolute simplest no-advanced-tooling way might be to literally copy the relevant WIT files into wit/deps for two projects locally. That should help build confidence as to what the tooling is expected to do, and then you can pull in wkg and stuff.
Would appreciate if you filed an issue to component-docs (the more you could include about what exactly was confusing, what the docs should have said/demonstrated to help you better, the better!)
I've put together a small repo that should help explain this (but contains no integration code):
https://github.com/vados-cosmonic/example-simple-wit-reuse
Figure this might be better than giving tree output.
(all of this is useful after reading the already posted links of course!)
Last updated: Dec 06 2025 at 05:03 UTC