A modern code snippet manager that allows developers to create, save, organize, and share code snippets with features like syntax highlighting, public/private visibility, screenshot export, and AI-powered enhancements, backed by a freemium subscription model.
🚀 Live Demo: snippet-studio-lovat.vercel.app
Snippet Studio is a full-stack TypeScript application built with Next.js 15 that helps developers manage their code snippets effectively. The platform combines a rich code editor with real-time database synchronization, authentication, payment processing, and AI-powered features to provide a comprehensive snippet management solution.
Key Highlights:
- Built with Next.js 15 App Router and React 19
- Real-time backend powered by Convex
- Secure authentication via Clerk
- Freemium model with Stripe subscriptions (30 free snippets, unlimited for Pro)
- AI features using Anthropic's Claude API
- Responsive design with dark/light theme support
- Create and Edit Snippets: Full-featured code editor with CodeMirror integration
- Syntax Highlighting: Support for 28+ programming languages via Highlight.js
- Tag System: Organize snippets with custom tags and filter by tag or language
- Real-time Search: Instantly search snippets by title, language, or tags
- Public/Private Visibility: Toggle between public and private snippet sharing
- One-Click Sharing: Generate shareable links for public snippets
- Screenshot Export: Export beautiful code screenshots with:
- 8 customizable gradient backgrounds
- macOS-style window chrome
- PNG download or clipboard copy
- Language badges and tag display
- Social Sharing: Direct sharing to X (Twitter), LinkedIn, Reddit, WhatsApp, and Telegram
- Native Share API: Mobile-optimized sharing experience
- Code Explanation: Get AI-generated explanations of your code
- Tag Suggestions: Automatic tag recommendations based on code content
- Title Generation: AI-powered snippet title suggestions
- Theme Support: Dark and light mode with system preference detection
- Responsive Design: Optimized for desktop, tablet, and mobile
- Usage Tracking: Visual progress bars showing snippet quota usage
- Statistics Dashboard: View total, public, and private snippet counts
- Unlimited snippets (vs. 30 for free)
- Private snippet support
- Screenshot export functionality
- Full access to AI features
- Priority support
- Framework: Next.js 15 with App Router and Turbopack
- UI Library: React 19
- Language: TypeScript 5
- Styling: TailwindCSS 4 with custom theme
- UI Components: shadcn/ui (Radix UI primitives)
- Code Editor: CodeMirror 6 with language extensions
- Syntax Highlighting: Highlight.js
- Theme Management: next-themes
- Forms: React Hook Form with Zod validation
- Database & API: Convex (serverless real-time backend)
- Authentication: Clerk with Next.js integration
- Payments: Stripe (subscription management)
- AI Integration: Anthropic AI SDK (Claude)
- Package Manager: npm/yarn
- Linting: ESLint 9 with Next.js config
- Deployment: Vercel (frontend) + Convex (backend)
- Concurrent Scripts: npm-run-all
Before you begin, ensure you have the following installed:
- Node.js: Version 20 or higher
- npm or yarn: Latest version
- Git: For cloning the repository
You'll also need accounts for:
- Clerk - Authentication
- Convex - Backend database
- Stripe - Payment processing
- Anthropic - AI features
git clone https://github.com/hasnatamir2/snippet-studio.git
cd snippet-studionpm install
# or
yarn installnpx convex devThis command will:
- Create a new Convex project (if you don't have one)
- Generate your
NEXT_PUBLIC_CONVEX_URL - Set up the local development environment
- Create a new application at clerk.com
- Copy your publishable and secret keys
- Configure sign-in/sign-up pages in Clerk dashboard
- Create a Stripe account at stripe.com
- Create a product with a monthly price (e.g., $9/month for Pro)
- Copy your secret key, publishable key, and webhook secret
- Set up webhook endpoint:
https://yourdomain.com/api/stripe/webhook
- Sign up at anthropic.com
- Generate an API key from your dashboard
Create a .env.local file in the root directory with the following variables:
# Convex
NEXT_PUBLIC_CONVEX_URL=https://your-convex-deployment.convex.cloud
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxxxxxxxxxxxx
CLERK_SECRET_KEY=sk_test_xxxxxxxxxxxxx
# Stripe Payments
STRIPE_SECRET_KEY=sk_test_xxxxxxxxxxxxx
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_xxxxxxxxxxxxx
STRIPE_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxx
NEXT_PUBLIC_STRIPE_PRICE_PRO_MONTHLY=price_xxxxxxxxxxxxx
# Anthropic AI
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxx
# Application URL
NEXT_PUBLIC_APP_URL=http://localhost:3000| Variable | Description | Example |
|---|---|---|
NEXT_PUBLIC_CONVEX_URL |
Your Convex deployment URL | https://xxx.convex.cloud |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY |
Clerk public key | pk_test_xxx |
CLERK_SECRET_KEY |
Clerk secret key | sk_test_xxx |
STRIPE_SECRET_KEY |
Stripe secret key | sk_test_xxx |
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY |
Stripe public key | pk_test_xxx |
STRIPE_WEBHOOK_SECRET |
Stripe webhook signing secret | whsec_xxx |
NEXT_PUBLIC_STRIPE_PRICE_PRO_MONTHLY |
Stripe price ID for Pro plan | price_xxx |
ANTHROPIC_API_KEY |
Anthropic API key | sk-ant-xxx |
NEXT_PUBLIC_APP_URL |
Your app's URL | http://localhost:3000 |
npm run devThis command runs both frontend and backend concurrently:
- Frontend:
http://localhost:3000 - Convex dev server: automatically started
npm run dev:frontendnpm run dev:backend# Build the application
npm run build
# Start production server
npm run start- Push your code to GitHub
- Import the project in Vercel
- Add all environment variables in Vercel dashboard
- Deploy Convex to production:
npx convex deployUpdate your NEXT_PUBLIC_CONVEX_URL in Vercel to the production URL.
snippet-studio/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── api/ # API routes
│ │ │ ├── snippet-meta/ # OG image metadata
│ │ │ └── stripe/ # Stripe webhooks & handlers
│ │ ├── billing/ # Billing and payment pages
│ │ │ └── payment/ # Checkout page
│ │ ├── dashboard/ # User dashboard
│ │ ├── new/ # Create snippet page
│ │ ├── sign-in/ # Clerk sign-in
│ │ ├── sign-up/ # Clerk sign-up
│ │ ├── snippets/ # Snippet viewer
│ │ │ └── [snippetId]/ # Dynamic snippet route
│ │ ├── globals.css # Global styles
│ │ ├── icon.svg # App icon
│ │ ├── layout.tsx # Root layout
│ │ └── page.tsx # Landing page
│ ├── components/ # React components
│ │ ├── app-sidebar/ # Sidebar navigation
│ │ ├── code-block/ # Code display components
│ │ │ ├── code-block.tsx # Static code display
│ │ │ └── code-input.tsx # CodeMirror editor
│ │ ├── convex/ # Convex React providers
│ │ ├── landing/ # Landing page components
│ │ ├── snippets/ # Snippet-related components
│ │ │ ├── snippet-card.tsx # Snippet list card
│ │ │ ├── snippet-explanation.tsx
│ │ │ ├── snippet-form.tsx # Create/edit form
│ │ │ ├── snippet-screenshot.tsx
│ │ │ ├── snippet-usage-tracker.tsx
│ │ │ ├── snippets-list.tsx
│ │ │ ├── share-panel.tsx
│ │ │ └── tag-input.tsx
│ │ ├── stripe/ # Stripe components
│ │ ├── ui/ # shadcn/ui components
│ │ ├── clerk-provider.tsx
│ │ ├── error-boundary.tsx
│ │ ├── header.tsx
│ │ └── theme-provider.tsx
│ ├── hooks/ # Custom React hooks
│ │ └── use-mobile.ts
│ ├── lib/ # Utility functions
│ │ ├── constant.ts # App constants
│ │ └── utils.ts # Helper functions
│ └── middleware.ts # Clerk middleware
├── convex/ # Convex backend
│ ├── _generated/ # Auto-generated types
│ ├── actions/ # Convex actions
│ │ ├── ai.ts # AI features
│ │ └── stripe.ts # Stripe integration
│ ├── http.ts # HTTP endpoints
│ ├── mutations/ # Database mutations
│ │ ├── snippet.ts
│ │ └── users.ts
│ ├── queries/ # Database queries
│ │ ├── snippets.ts
│ │ └── user.ts
│ ├── schema.ts # Database schema
│ └── tsconfig.json
├── public/ # Static assets
├── .eslintrc.json # ESLint config
├── package.json # Dependencies
├── tailwind.config.ts # Tailwind config
├── tsconfig.json # TypeScript config
└── README.md # This file
src/app/: Next.js 15 App Router pages and layoutssrc/components/: Reusable React components organized by featureconvex/: Backend logic, database schema, and serverless functionssrc/lib/: Shared utilities and constants
-
Sign Up/Sign In
- Visit the homepage and click "Sign up"
- Complete Clerk authentication flow
-
Create a Snippet
- Click "New snippet" in the header
- Enter your code in the editor
- The language is auto-detected, or manually select from 28+ options
- Add a title (or use AI to generate one)
- Add tags for organization
- Toggle public/private visibility
- Click "Save Snippet" or press
Cmd+S/Ctrl+S
Navigate to /dashboard to see all your snippets with:
- Stats Cards: Total, public, private snippet counts, and plan status
- Search Bar: Real-time search by title, language, or tag
- Language Filters: Quick filter pills for each language
- Snippet Cards: Grid view with actions
- Edit: Click pencil icon to modify
- Copy Code: Click copy icon to copy code to clipboard
- Delete: Click trash icon (requires confirmation)
- Toggle Visibility: Lock/unlock icon to change public/private status
- Share: Share icon (only visible for public snippets)
The CodeMirror-based editor includes:
- Theme Toggle: Switch between light and dark modes
- Font Size Control: Choose SM (13px), MD (15px), or LG (17px)
- Line Numbers: Toggle line number visibility
- Keyboard Shortcut: Save with
Cmd+SorCtrl+S - Language Support: Auto-detection with manual override
- Click "Screenshot" on any snippet
- Select a gradient background (8 options available)
- Export options:
- Download PNG: Save to your device
- Copy Image: Copy to clipboard
- Share: Use native sharing (mobile) or social platforms
The screenshot includes:
- macOS-style window chrome
- Language badge
- Snippet tags (if present)
- Custom gradient background
- Open any snippet
- Click "Explain" in the toolbar
- AI generates a detailed explanation of your code
- After saving a snippet, AI automatically suggests relevant tags
- Click on suggested tags to add them to your snippet
- Write your code
- Click the sparkle icon next to the title field
- AI generates a descriptive title
- Toggle snippet to public
- Click "Share" button
- Copy link or share directly to:
- X (Twitter)
- Telegram
- Only visible to the owner
- Share button is disabled
- Cannot be accessed via direct URL by others
Search Bar:
Type: "react hooks"
Matches: Titles, languages, and tags containing "react" or "hooks"
Language Filters:
- Click "All" to view all snippets
- Click any language pill to filter by that language
- Active filters are highlighted
Combined Search:
- Use search bar and language filter together
- Results update in real-time
Price: $0/month
Features:
- 30 snippets maximum
- Public snippet sharing
- Syntax highlighting for 28+ languages
- Tags and search
- Real-time sync
Limitations:
- No private snippets
- No screenshot export
- No AI features
- No priority support
Price: $9/month
**Features