I want to create an match with password and no one cant join without password

i cant find anything for set a password to my match i created

  1. Versions: Nakama {3.5}, {Windows, Mac, Linux binary or Docker}, {client library (SDK) and version}
  2. Server Framework Runtime language (If relevant) {Go, TS/JS, Lua}
{code or log snippet}

:tv: Media:

Hi @TheNeSSePa,

Matches with passwords are not supported out of the box, but it is very easy to set this up using a Before Hook.

You didn’t mention which client SDK or server runtime language you were using, but here is an example using Go. Here we add a Before Hook on the MatchJoin realtime message and check the incoming meta data for a password value. If the password is correct (your logic here will vary) then we allow the request by returning the original envelope value, otherwise we return a permission denied error.

errMatchPermissionDenied := runtime.NewError("permission denied, invalid match password", 7)
initializer.RegisterBeforeRt("MatchJoin", func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, in *rtapi.Envelope) (*rtapi.Envelope, error) {
	envelope, ok := in.Message.(*rtapi.Envelope_MatchJoin)
	if !ok {
		return nil, runtime.NewError("error getting envelope as MatchJoin", 13)

	if password, ok := envelope.MatchJoin.Metadata["password"]; ok {
		// Check if password is valid
		if password == "the_correct_password" {
			return in, nil

	return nil, errMatchPermissionDenied

On the client side you can pass this password when joining a match.

await socket.JoinMatchAsync("match_id", new Dictionary<string, string>{ { "password", "the_correct_password" } });

hi tom thanks for your replay is works for me
can u please do this for js and lua too for unity sdk?

Please see the documentation here Heroic Labs Documentation | Using Hooks

You can change the server language at the top of the page.

thanks tom for reply

1 Like