Calling early-stage startups: apply to the Neon Startup Program and get up to $100k in credits
Docs/Neon Auth/Next.js SDK/ContactChannel

ContactChannel

beta

Neon Auth ContactChannel object reference

This is a reference for the ContactChannel type in the Next.js SDK.

Represents a contact method (email, phone, etc.) for a user.

ContactChannel represents a user's contact information, such as an email address or phone number. Some auth methods, like OTP/magic link or password, use contact channels for authentication.

On this page:

ContactChannel

Basic information about a contact channel, as seen by a user themselves.

Usually obtained by calling user.listContactChannels() or user.useContactChannels().

Type Definition

type ContactChannel = {
  id: string;
  value: string;
  type: 'email';
  isPrimary: boolean;
  isVerified: boolean;
  usedForAuth: boolean;

  sendVerificationEmail(): Promise<void>;
  update(options): Promise<void>;
  delete(): Promise<void>;
};

contactChannel.id

The id of the contact channel as a string.

declare const id: string;

contactChannel.value

The value of the contact channel. If type is "email", this is an email address.

declare const value: string;

contactChannel.type

The type of the contact channel. Currently always "email".

declare const type: 'email';

contactChannel.isPrimary

Indicates whether the contact channel is the user's primary contact channel. If an email is set to primary, it will be the value on the user.primaryEmail field.

declare const isPrimary: boolean;

contactChannel.isVerified

Indicates whether the contact channel is verified.

declare const isVerified: boolean;

contactChannel.usedForAuth

Indicates whether the contact channel is used for authentication. If set to true, the user can use this contact channel with OTP or password to sign in.

declare const usedForAuth: boolean;

contactChannel.sendVerificationEmail()

Sends a verification email to this contact channel. Once the user clicks the verification link in the email, the contact channel will be marked as verified.

Parameters

None.

Returns

Promise<void>

declare function sendVerificationEmail(): Promise<void>;

Example

await contactChannel.sendVerificationEmail();

contactChannel.update(options)

Updates the contact channel. After updating the value, the contact channel will be marked as unverified.

Parameters

  • options: An object containing properties for updating.
    • value: The new value of the contact channel.
    • type: The new type of the contact channel. Currently always "email".
    • usedForAuth: Indicates whether the contact channel is used for authentication.
    • isPrimary: Indicates whether the contact channel is the user's primary contact channel.

Returns

Promise<void>

declare function update(options: {
  value?: string;
  type?: 'email';
  usedForAuth?: boolean;
  isPrimary?: boolean;
}): Promise<void>;

Example

await contactChannel.update({ value: 'new-email@example.com' });

contactChannel.delete()

Deletes the contact channel.

Parameters

None.

Returns

Promise<void>

declare function delete(): Promise<void>;

Example

await contactChannel.delete();
Was this page helpful?