Skip to main content
important

This is a contributors guide and NOT a user guide. Please visit these docs if you are using or evaluating SuperTokens.

Golang

  • Use pointers when:

    • Need to pass by reference
    • Need to make something optional
  • When returning an object from an API or recipe function, and if the object has different status types, each status type should correspond to a nullable sub-object. For example, if the return type of a function is:

    {status: "OK", name: string} | {status: "SOME_ERROR"}

    This should be like the following in go:

    type Response struct {
    OK *struct{
    Name string
    },
    SomeError *struct{}
    }

    Then the consumer of the function can check if response.OK != nil or response.SomeError != nil

  • When parsing JSON response from an API, one method is to first marshall it (convert it to string JSON) and then unmarshall it into an object.

  • Package names for defining types / models must be globally unique (based on short form of recipe name, for example epmodels for email password models). This is so that importing them and using them across recipes should be easy.

Which frontend SDK do you use?
supertokens-web-js / mobile
supertokens-auth-react