I am having some troubles using the spl-token library. How do I use it?

<script src="https://cdn.jsdelivr.net/npm/@solana/[email protected]/lib/cjs/index.min.js"></script>

It is included it like that!

How do I use it now? For Solana web3, I simply use solanaWeb3.function(), but it doesn’t work for spl.

I also tried with this in my JavaScript file: const { TOKEN_PROGRAM_ID, Token} = splToken;, but then I get this error:

Uncaught ReferenceError: splToken is not defined

1 Answer 1


@solana/spl-token does not export a global like @solana/web3.js does. It's an ES/CommonJS module intended to be bundled with your app.

Nominally, you could use an ES Module import like this:

<script type="module">
  import splToken from 'https://cdn.jsdelivr.net/npm/@solana/[email protected]/+esm';

…but even then you will have other trouble – namely that uuid has broken exports.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.