@vue-solana/core
v0.3.3
Published
Framework-agnostic primitives for Vue Solana libraries.
Readme
@vue-solana/core
Framework-agnostic Solana primitives used by the Vue Solana packages.
Use this package directly when you want connection helpers, shared wallet types, Android Mobile Wallet Adapter registration helpers, and transaction helpers without installing the Vue plugin.
@vue-solana/core does not replace @solana/web3-compat. Use @solana/web3-compat for raw Solana primitives like Connection, PublicKey, and transactions. Use @vue-solana/core for Vue Solana shared configuration, cluster endpoint defaults, wallet interfaces, and transaction helpers.
Official Solana docs:
Full Vue Solana docs:
Install
pnpm add @vue-solana/core @solana/web3-compatnpm install @vue-solana/core @solana/web3-compatQuick Start
import { createSolanaContext } from "@vue-solana/core";
const solana = createSolanaContext({
cluster: "devnet",
});
const { blockhash } = await solana.connection.getLatestBlockhash();
console.log(solana.endpoint, blockhash);The root export remains supported. Direct subpath exports are also available for narrower imports:
import { createSolanaContext } from "@vue-solana/core/rpc";
import type { SolanaConfig } from "@vue-solana/core/types";Configuration
import type { SolanaConfig } from "@vue-solana/core";
const config: SolanaConfig = {
cluster: "devnet",
endpoint: "https://api.devnet.solana.com",
wsEndpoint: "wss://api.devnet.solana.com",
commitment: "confirmed",
autoConnect: false,
};Supported clusters are mainnet-beta, testnet, devnet, and localnet. If endpoint is omitted, the package uses the public Solana RPC endpoint for the selected cluster. If wsEndpoint is omitted, it is derived from the RPC endpoint.
Use mainnet-beta for Solana mainnet. This is Solana's official cluster name; the package intentionally does not use mainnet as an alias.
For development, use devnet and request free test SOL from the official faucet:
https://faucet.solana.comAPI
Direct subpaths:
@vue-solana/core/types@vue-solana/core/clusters@vue-solana/core/rpc@vue-solana/core/mobile-wallet@vue-solana/core/transaction@vue-solana/core/wallet@vue-solana/core/wallet-standardDEFAULT_CLUSTER: default cluster, currentlydevnet.createSolanaConnection(config?): creates aConnection.createSolanaContext(config?): creates{ cluster, endpoint, wsEndpoint, connection }.getClusterEndpoint(cluster?): returns the HTTP RPC endpoint for a cluster.getClusterWebSocketEndpoint(cluster?): returns the WebSocket endpoint for a cluster.getWebSocketEndpoint(endpoint): convertshttp/httpsRPC URLs tows/wssURLs.isWalletConnected(wallet): checks whether a wallet is connected and has a public key.assertWalletConnected(wallet): throws if the wallet is not connected.assertWalletCanSign(wallet): throws if the wallet cannot sign transactions.signAndSendTransaction(connection, wallet, transaction, options?): signs and sends a transaction using a configured wallet. Android Mobile Wallet Adapter wallets prefersignTransactionplus app-side RPC submission when available so the app can reliably return the submitted signature.
Wallet Interface
import type { SolanaWallet } from "@vue-solana/core";
const wallet: SolanaWallet = {
publicKey: null,
connected: false,
connect: async () => {},
disconnect: async () => {},
signTransaction: async (transaction) => transaction,
};Browser extension wallets discovered through the Solana Wallet Standard are adapted into SolanaWallet. Android Mobile Wallet Adapter is registered through @solana-mobile/wallet-standard-mobile and then adapted through the same Wallet Standard adapter on supported Android Chrome clients. You can also provide a custom object that implements SolanaWallet for tests or custom adapters.
Current wallet support:
- Browser extension wallets through Wallet Standard packages.
- Android native mobile wallets through
@solana-mobile/wallet-standard-mobileon Android Chrome and Chrome PWAs. - Manual/custom wallet objects that implement
SolanaWallet.
Planned but not supported yet:
- iOS browser wallets through wallet-specific universal link or deep link adapters.
- Desktop native app wallets through wallet-specific protocol links or future native Wallet Standard registration.
Examples
For complete runnable Vue and Nuxt examples that use this package through the framework integrations, see:
- Live demo
- examples/vue-vite
- examples/nuxt
AI Agent Skill
If you use an AI coding agent, install the Vue Solana Agent Skill for package selection, setup patterns, wallet flow guidance, Solana-specific gotchas, and verification commands:
npx skills add vue-solana/vue-solana --skill vue-solanaDocs: Vue Solana Agent Skill
Known TypeScript Issue
@solana/[email protected] currently has broken TypeScript metadata. Runtime imports still use the real package, but TypeScript consumers may need a local declaration shim.
If TypeScript cannot resolve @solana/web3-compat, add types/web3-compat.d.ts to your app:
declare module "@solana/web3-compat" {
export type { Commitment, SendOptions, TransactionSignature } from "@solana/web3.js";
export {
Connection,
Keypair,
PublicKey,
SystemProgram,
Transaction,
TransactionInstruction,
VersionedTransaction,
} from "@solana/web3.js";
}Make sure your tsconfig.json includes types/**/*.d.ts or another pattern that includes the shim.
Status
This package is early-stage. RPC helpers, browser extension wallet primitives, Android mobile wallet registration, and transaction helpers are usable.
