Test Mode (Web SDK Only)

Test Mode (Web SDK Only)

Magic client SDKs provide Test Mode as a quick way to test your integration locally by asserting specific error codes or bypassing the magic link flow completely.


To enable Test Mode, provide testMode: true to the SDK constructor.

import { Magic } from 'magic-sdk'; const magic = new Magic('YOUR_API_KEY', { testMode: true, });

With Test Mode enabled, you can assert the desired behavior through the email address you provide to loginWithMagicLink.

To assert a success state, use test+success@magic.link.

magic.auth.loginWithMagicLink({ email: 'test+success@magic.link' });

Users created in test mode are ephemeral. It is advised that you do not associate these users to persistent data in your backend. If you are building an integration with cryptocurrency or Web3 features, please take a look at the advanced usage section below.

To assert a failed state, use test+fail@magic.link.

magic.auth.loginWithMagicLink({ email: 'test+fail@magic.link' });

To assert a case-specific failed state, you can also provide an RPC error code with test+fail_with_{RPC_ERROR_CODE}@magic.link.

import { RPCErrorCode } from 'magic-sdk'; magic.auth.loginWithMagicLink({ email: `test+fail_with_{${RPCErrorCode.MagicLinkFailedVerification}}@magic.link` }); magic.auth.loginWithMagicLink({ email: `test+fail_with_{${RPCErrorCode.MagicLinkExpired}}@magic.link` }); magic.auth.loginWithMagicLink({ email: `test+fail_with_{${RPCErrorCode.MagicLinkRateLimited}}@magic.link` }); ...

You can find a list of relevant RPC error codes here.

Advanced Usage

Web3 and blockchain use-cases sometimes require access to deterministic key-pairs so that testnet funds are available at runtime. To enable this, users can explicitly specify the key-pair associated to a test user, like so:


The key-pair provided in the email address during test mode is not protected by Magic's delegated key management system. These keys should not be considered secure or private. Never store mainnet funds with these keys!

In practice, you can assert a successful login with:

magic.auth.loginWithMagicLink({ email: 'test+success_with_{0x89A3983da27fF0eFCF901F74C4df84e0450A17B7:0x19de850af732e9e5745915162d707d6d8cf013ce7b2862e93081b0c8883bdfae}@magic.link', });

In the example above, we encode an Ethereum-compatible key-pair in the test user's email address. The login method will immediately resolve with a success state, bypassing the passwordless flow and enabling Ethereum or EVM-compatible signing methods to work seamlessly with your existing Web3 code.

Coming soon

Admin-sdk support for testMode!

Test Mode (Web SDK Only)