Skip to content

jynxbt/Polyq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polyq

DX toolkit for Solana and EVM. Framework-agnostic DX tooling — polyfills, IDL sync, codegen, and workspace orchestration.

Works with React, Next.js, Svelte, SvelteKit, Remix, Nuxt, or any Vite/webpack project.

Install

npm install polyq

Quick Start

React / Vite

// vite.config.ts
import { polyqVite } from 'polyq/vite'

export default defineConfig({
  plugins: [polyqVite()],
})

Next.js

// next.config.ts
import { withPolyq } from 'polyq/next'

const nextConfig = { /* ... */ }
export default withPolyq(nextConfig)

SvelteKit

// vite.config.ts
import { sveltekit } from '@sveltejs/kit/vite'
import { polyqSvelteKit } from 'polyq/sveltekit'

export default defineConfig({
  plugins: [sveltekit(), ...polyqSvelteKit()],
})

Remix

// vite.config.ts
import { vitePlugin as remix } from '@remix-run/dev'
import { polyqRemix } from 'polyq/remix'

export default defineConfig({
  plugins: [remix(), ...polyqRemix()],
})

Nuxt

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['polyq/nuxt'],
  polyq: {
    polyfills: { buffer: true },
    idlSync: {
      mapping: { my_program: ['packages/sdk/src/idl.json'] },
    },
  },
})

Raw Webpack

// webpack.config.js
import { polyqWebpack } from 'polyq/webpack'

const applyHelm = polyqWebpack()

export default applyHelm({
  entry: './src/index.ts',
  // ...
})

Features

Automatic Polyfills

Zero-config. Detects Solana dependencies and auto-configures:

  • globalglobalThis
  • buffer alias → npm buffer package
  • optimizeDeps (Vite) / resolve.fallback + ProvidePlugin (webpack)

SSR-aware — polyfills only apply to client builds.

IDL Sync + HMR

Watch target/idl/ and auto-sync to your frontend on every anchor build:

// Any Vite-based framework
polyqVite({
  idlSync: {
    watchDir: 'target/idl',
    mapping: {
      my_program: ['packages/sdk/src/idl.json'],
    },
  },
})

No manual copying, no page refresh. The Vite dev server picks up IDL changes via HMR.

Codegen

Generate TypeScript clients from Anchor IDLs:

polyq codegen                          # All IDLs in target/idl/
polyq codegen --idl target/idl/my_program.json --out generated/
polyq codegen --watch                  # Watch + regenerate

Generates:

  • Types — TypeScript interfaces from IDL type definitions
  • PDAsderiveFoo() functions from IDL seed definitions
  • InstructionscreateFooInstruction() builders with typed accounts/args
  • Accounts — Discriminator constants and fetch stubs
  • Errors — Error enum and lookup function

Smart Workspace (CLI)

Stage-based dev environment orchestration with proper health check polling:

polyq dev              # Docker → Validator → Build → Deploy → Init → DB → Dev Server
polyq dev --quick      # Skip program builds
polyq dev --reset      # Drop DB, clear ledger, full rebuild
polyq stop             # Stop services
polyq stop --all       # Also stop Docker
polyq status           # Show what's running
polyq build            # Build programs
polyq build --features local --parallel

Replaces hundreds of lines of shell scripts with a single config:

// polyq.config.ts
import { defineHelmConfig } from 'polyq'

export default defineHelmConfig({
  workspace: {
    buildFeatures: ['local'],
    docker: { services: ['postgres'] },
    validator: { rpcUrl: 'http://127.0.0.1:8899' },
    init: { script: 'scripts/init.ts' },
    database: {
      url: 'postgresql://dev:dev@localhost:5433/myapp',
      migrationsDir: 'migrations',
      seed: { script: 'seed:dev' },
    },
    devServer: { command: 'bun run dev' },
  },
})

Framework Support Matrix

Feature Vite (React, Svelte, etc.) Next.js SvelteKit Remix Nuxt
Auto Polyfills polyqVite() withPolyq() polyqSvelteKit() polyqRemix() module
IDL Sync + HMR yes yes yes yes
Codegen (CLI) yes yes yes yes yes
Smart Workspace yes yes yes yes yes

IDL Sync requires Vite's dev server for HMR. Next.js projects get polyfills + codegen + workspace, but not hot IDL reload.

License

MIT

About

Chain-agnostic DX toolkit — auto-polyfills, schema sync, codegen, and workspace orchestration for Solana and EVM dApps.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors