Vue Solana keeps cluster and endpoint configuration shared across @vue-solana/core, @vue-solana/vue, and @vue-solana/nuxt.
Use this guide when you need to choose a cluster, provide a custom RPC endpoint, or understand what the RPC composables expose.
Cluster Names
Supported cluster names are:
devnettestnetmainnetmainnet-beta(legacy alias formainnet)localnet
Use mainnet for Solana mainnet. This is Solana's official mainnet cluster name. The legacy mainnet-beta spelling is still accepted and redirects to the same endpoint.
devnet is the default because it is the safest cluster for examples and development.
Core Setup
Use @vue-solana/core/rpc when you want framework-agnostic client setup.
import { createSolanaContext } from "@vue-solana/core/rpc";
const solana = createSolanaContext({
cluster: "devnet",
commitment: "confirmed",
});
const { value: latestBlockhash } = await solana.client.rpc.getLatestBlockhash().send();
console.log(solana.endpoint, latestBlockhash.blockhash);
createSolanaContext() returns the resolved cluster, HTTP endpoint, WebSocket wsEndpoint, and a Kit client whose rpc sends RPC requests.
Custom RPC Endpoints
Production apps should usually use a dedicated RPC provider instead of public cluster endpoints.
import { createSolanaContext } from "@vue-solana/core/rpc";
const solana = createSolanaContext({
cluster: "mainnet",
endpoint: "https://your-rpc.example.com",
commitment: "confirmed",
});
If wsEndpoint is omitted, Vue Solana derives it from the HTTP endpoint by converting https to wss and http to ws.
import { getWebSocketEndpoint } from "@vue-solana/core/clusters";
const wsEndpoint = getWebSocketEndpoint("https://api.devnet.solana.com");
Hosted RPC Setup
The built-in devnet endpoint is fine for a first read. For an example you plan to keep, or for an app that uses WebSocket subscriptions, create a free keyed endpoint with a provider such as Chainstack or Alchemy. The cluster concepts compare their free tiers and trade-offs.
Pass the provider's HTTP URL as endpoint:
createSolanaPlugin({
cluster: "devnet",
endpoint: "https://solana-devnet.g.alchemy.com/v2/YOUR_KEY",
});
wsEndpoint is optional. Vue Solana converts https to wss automatically, so the WebSocket URL is derived from the HTTP URL above. Pass wsEndpoint explicitly only when the provider uses a different host or port.
For Nuxt, keep a server-only key in private runtime config and read it with useServerSolanaClient() as shown in Server-Side RPC During SSR. Never put a raw key in runtimeConfig.public.solana; public config is bundled into the browser. In a pure client app the endpoint string is visible by design, so use the provider's domain/IP allowlist and keep the key out of source control.
Free tiers are for learning and low traffic. Before relying on useProgramAccounts(), useTokenAccounts(), or historical lookups, check the provider's method availability: the same method can be included on devnet and restricted on mainnet, or require an archive plan.
Vue Setup
Install the Vue plugin once near app startup.
import { createApp } from "vue";
import { createSolanaPlugin } from "@vue-solana/vue";
import App from "./App.vue";
createApp(App)
.use(
createSolanaPlugin({
cluster: "devnet",
commitment: "confirmed",
}),
)
.mount("#app");
Then read RPC state from components with useRpc().
<script setup lang="ts">
import { useRpc } from "@vue-solana/vue/useRpc";
const { cluster, endpoint, status, latestBlockhash, error, checkConnection } = useRpc();
</script>
<template>
<section>
<p>Cluster: {{ cluster }}</p>
<p>Endpoint: {{ endpoint }}</p>
<p>Status: {{ status }}</p>
<p>Latest blockhash: {{ latestBlockhash }}</p>
<p v-if="error">Unable to reach RPC.</p>
<button type="button" @click="checkConnection">Check RPC</button>
</section>
</template>
Nuxt Setup
Configure the module in nuxt.config.ts.
export default defineNuxtConfig({
modules: ["@vue-solana/nuxt"],
solana: {
cluster: "devnet",
commitment: "confirmed",
},
});
Nuxt stores module options in public runtime config, so options must be JSON-serializable. The Nuxt module intentionally omits payer and payerSecretKey; never place a raw secret in public runtime config. Install an ephemeral payer in a client-only plugin with clientPlugin: false.
Direct core and Vue clients can pass payer or payerSecretKey to createSolanaClient() / createSolanaPlugin(). The default client uses the official solanaRpc() stack for client-sent transactions, and solanaRpc() installs the transaction planner and the plan-signing and plan-sending executors itself.
Use the auto-imported useSolanaRpc() composable in Nuxt pages and components.
<script setup lang="ts">
const { cluster, endpoint, status, checkConnection } = useSolanaRpc();
</script>
The Nuxt browser runtime plugin is client-only, but a server plugin installs a request-scoped context during SSR using the configured cluster and endpoints, so useSolanaRpc() renders the configured cluster instead of a hardcoded devnet. Wallet state is inert until hydration; keep wallet work in client lifecycle hooks or user actions.
Server-Side RPC During SSR
A Nuxt page can render Solana data on the server and hand it to the component with useAsyncData(). Auto-imported composables are safe to call during SSR, but they stay inert: no RPC reads, subscriptions, wallet prompts, or sends start before hydration. Anything that must appear in the initial HTML belongs in a Nitro route.
Private configuration
Keep the RPC URL and any API key in private runtime config under solanaServer. The server helpers accept only read-side options (cluster, endpoint, commitment), strip wallet, payer, and payerSecretKey at runtime, and return a read-only client with no WebSocket subscriptions. That keeps Kit's Node ws channel out of the Nitro bundle, so you do not need vite.ssr.external: ["ws"]. Never put secrets in runtimeConfig.public.solana, which is bundled into the browser.
export default defineNuxtConfig({
modules: ["@vue-solana/nuxt"],
solana: {
cluster: "mainnet",
},
runtimeConfig: {
solanaServer: {
// Private: this value is never bundled into the browser.
endpoint: process.env.SOLANA_RPC_URL,
commitment: "confirmed",
},
},
});
Direct server client
createServerSolanaClient() creates an independent, read-only client when a route needs explicit options or its own lifetime. useServerSolanaClient() reads the current request's private config for the common case. Both return the HTTP rpc surface only: there is no rpcSubscriptions, airdrop, planner, or send capability, and no WebSocket is opened. Use client.rpc.* and the read helpers below; use the browser composables for subscriptions, signing, and sending.
// server/api/version.get.ts
import { createServerSolanaClient } from "@vue-solana/nuxt/server";
export default defineEventHandler(async () => {
const client = createServerSolanaClient({ commitment: "confirmed" });
return await client.rpc.getVersion().send();
});
Nitro route
Return only the fields the page needs, and convert bigint values such as slot numbers and balances to strings.
// server/api/slot.get.ts
import { useServerSolanaClient } from "@vue-solana/nuxt/server";
export default defineEventHandler(async () => {
const { rpc } = useServerSolanaClient();
const slot = await rpc.getSlot().send();
return { slot: slot.toString() };
});
Then fetch it during SSR with useAsyncData():
<script setup lang="ts">
const { data, refresh } = await useAsyncData("solana-slot", () =>
$fetch<{ slot: string }>("/api/slot"),
);
</script>
<template>
<p>Slot: {{ data?.slot ?? "Loading..." }}</p>
<button type="button" @click="refresh()">Refresh</button>
</template>
The result is stored in the Nuxt payload, so hydration does not refetch it.
Read-only composable patterns
The Vue composables do not fetch or subscribe during server rendering. Use their core equivalents in a Nitro route, then pass the serialized result through useAsyncData().
These routes import helpers from @vue-solana/core subpaths. Add @vue-solana/core as a direct dependency (pnpm add @vue-solana/core); pnpm's strict node_modules layout does not expose transitive packages to app code.
useRequest()/useTrackedData()— callclient.rpc.*directly in the route.useTokenPortfolio()—getTokenPortfolio(client, owner)from@vue-solana/core/token-portfolio.useProgramAccount()—fetchProgramAccount(client, input)from@vue-solana/core/program-clientwith a one-shot read; do not subscribe during SSR.useComputeBudget()—resolveFeePolicy(message, policy, { client })from@vue-solana/core/fee-policy; it estimates but never signs or sends.useTransactionDiagnostics()—buildDiagnosticReport({ ... })from@vue-solana/core/diagnostics; it joins data you already fetched.
// Inside a Nitro route; wire the serialized result into useAsyncData().
import { buildDiagnosticReport } from "@vue-solana/core/diagnostics";
import { resolveFeePolicy } from "@vue-solana/core/fee-policy";
import { fetchProgramAccount } from "@vue-solana/core/program-client";
import { getTokenPortfolio } from "@vue-solana/core/token-portfolio";
import { useServerSolanaClient } from "@vue-solana/nuxt/server";
const client = useServerSolanaClient();
const slot = await client.rpc.getSlot().send(); // useRequest / useTrackedData
const portfolio = await getTokenPortfolio(client, owner); // useTokenPortfolio
const account = await fetchProgramAccount(client, input); // useProgramAccount
const budget = await resolveFeePolicy(message, policy, { client }); // useComputeBudget
const report = buildDiagnosticReport({ signature, historyItem }); // useTransactionDiagnostics
SSR lifecycle rules
- Calling the composables during SSR is safe; state stays idle/disabled until hydration.
useProgramInstruction()only requiressendTransactionat setup. Itspayercheck and actualsend()are client-only; do not callsend()during SSR.- Start subscriptions after hydration. If streamed data must seed the HTML, take a one-shot read in the Nitro route instead.
- Wallet discovery, signing, and prompts stay in client components. Never move
wallet,payer, orpayerSecretKeyinto public runtime config.
Endpoint Helpers
Use @vue-solana/core/clusters when you need the built-in endpoint values without creating a client.
import {
DEFAULT_CLUSTER,
getClusterEndpoint,
getClusterWebSocketEndpoint,
} from "@vue-solana/core/clusters";
const endpoint = getClusterEndpoint(DEFAULT_CLUSTER);
const wsEndpoint = getClusterWebSocketEndpoint("devnet");
Production Notes
- Prefer a dedicated RPC provider for production traffic.
- Avoid broad or frequent scans on public RPC endpoints.
- Use WebSocket subscriptions intentionally; always clean them up when you no longer need them.
- Treat RPC responses as untrusted input and handle missing, stale, or failed data.