Skip to content

t1k:nakama:plugin

FieldValue
Modulebase
Version1.11.11
Effortlow
Tools—

Keywords: build, buildmode, go plugin, InitModule, plugin, runtime, shared object

/t1k:nakama:plugin

Nakama server loads custom Go code as shared-object plugins (.so). The plugin must export an InitModule function and match the host binary’s exact dependency versions.

func InitModule(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, initializer runtime.Initializer) error {
// Register RPCs, hooks, matches here
return nil
}
Terminal window
go build -trimpath -buildmode=plugin -o modules/backend.so ./modules
  • runtime.Initializer — register RPCs (RegisterRpc), hooks (RegisterBefore*, RegisterAfter*), matches
  • runtime.NakamaModule — authenticate users, read/write storage, send notifications
  • runtime.Logger — structured logging (Info, Warn, Error, Debug)
  • runtime.RUNTIME_CTX_* — context keys for user ID, session ID, env vars

Go plugins require exact binary compatibility with the host Nakama binary. All shared dependencies (protobuf, grpc, golang.org/x/*) must match pinned versions. See DEPENDENCY_PINS.md.

  • go.mod module path matches expected import path
  • All pinned deps match DEPENDENCY_PINS.md versions
  • Build succeeds: go build -trimpath -buildmode=plugin -o modules/backend.so ./modules
  • InitModule returns nil on success, wrapped error on failure
  • No fmt.Print* or log.* — use runtime.Logger exclusively