How to use `Accounts.onEmailVerificationLink`

I tried to user Account.onEmtailVerificationLink on client side

if (Meteor.isClient) {
  Accounts.onEmailVerificationLink(function (token, done) {
    console.log('inside onEmailVerificationLink');

    Accounts.verifyEmail(token, function (err) {
      if (err != null) {
      } else {
        console.log('Thank you! Your email address has been confirmed.')


don’t work, please help me.

Did you read

Also check out this post Email verification

I have a similar issue. Actually I think I understood how onEmailVerificationLink works but I just can’t figure out where to put it in my client code.

I tried to use this

./client/account.js or ./imports/client/account.js

import { Accounts } from 'meteor/accounts-base';

Accounts.onEmailVerificationLink(function (token, done) {
    console.log('verification link has been clicked', token)
    Accounts.verifyEmail(token, error => {
        if (!error) {

But nothing seems to happen. Do you guys have a clue of where I am supposed to put that function.

Thank you very much.

import { Accounts } from 'meteor/accounts-base'

// The following goes into onRendered (for Blaze) or equivalent in React - useEffect(() => , [])
// Pick up the token from the url.
// Check that your are logged in (the status is: logged in and email is not confirmed)

    Accounts.verifyEmail(token, err => {
         if (err?.reason === 'Verify email link expired') {
             // notify user the link is expired
      if (err) {
        // your preferred logger
        log('Could not verify email!', `Error: ${err.reason}`)
      } else {
        log('You\'ve Successfully Confirmed Your Email Address!')
        // your router or history function to direct to a valid route after login. Your curent route is probably '/verify-email/:token' or similar.

Thank you very much for your answer.

Indeed what you’ve send works fine and I am able to verify an account. I just wonder what’s the point of having an onEmailVerificationLink function (which by the way I haven’t been able to use properly so far) that can register what happens when a verification link is clicked if we can handle that into a component related to the verification process.

Is it a better practice to handle that with the onEmailVerificationLink function or is it okay to handle the whole process within the React component.

I suspect onEmailVerificationLink comes from the far history when “effects” where not so easy to implement.

I understand, thank you very much for the clarification. Have a nice day.