Quick Start
Get up and running with BlocksWeb in under 5 minutes. This guide will help you create a new BlocksWeb project, create your first component, and see it in the visual editor.
Prerequisites
Before you begin, make sure you have:
- Node.js 18+ installed (Download Node.js)
- Basic knowledge of React and TypeScript
- A code editor (VS Code recommended)
Step 1: Create a New Project
Open your terminal and run the following command:
npx create-blocksweb-app@latest my-blocksweb-projectThis will prompt you to enter a project name. The CLI will create a new Next.js project with BlocksWeb pre-configured.
TIP
The setup wizard will ask you to choose between App Router and Pages Router. Choose App Router if you're starting fresh (recommended for new projects).
Step 2: Install Dependencies
Navigate to your new project and install dependencies:
cd my-blocksweb-project
npm installThis may take a few minutes as it installs all necessary packages.
Step 3: Get Your API Key
BlocksWeb requires an API key to connect to the cloud service:
- Go to https://cloud.blocksweb.nl
- Sign up or sign in with your account
- Create a new workspace
- Copy your API key from the workspace settings
Step 4: Configure Environment Variables
Create a .env.local file in your project root:
# .env.local
BLOCKSWEB_API_KEY=your_api_key_here
BLOCKSWEB_WORKSPACE_ID=your_workspace_id_hereWARNING
Never commit your .env.local file to version control. Add it to .gitignore.
Step 5: Start the Development Server
Start your development server:
npm run devOpen http://localhost:3000 in your browser. You should see the BlocksWeb sign-in page.
Step 6: Sign In to the Editor
Click "Sign In" and use the same credentials from Step 3. After signing in, you'll see the BlocksWeb editor interface with an empty page.
Step 7: Create Your First Component
Create a new file components/Hero.tsx:
import { IBlockswebComponent } from '@blocksweb/core';
type HeroProps = {
title: string;
subtitle: string;
buttonText: string;
buttonUrl: string;
};
const Hero: IBlockswebComponent<HeroProps> = ({
title,
subtitle,
buttonText,
buttonUrl
}) => {
return (
<section className="hero">
<div className="container mx-auto px-4 py-16 text-center">
<h1 className="text-5xl font-bold mb-4">{title}</h1>
<p className="text-xl mb-8">{subtitle}</p>
<a
href={buttonUrl}
className="bg-blue-600 text-white px-8 py-3 rounded-lg hover:bg-blue-700"
>
{buttonText}
</a>
</div>
</section>
);
};
Hero.schema = {
displayName: 'Hero Section',
category: 'Marketing',
options: [
{
type: 'text',
name: 'title',
label: 'Title',
default: 'Welcome to Our Website'
},
{
type: 'text',
name: 'subtitle',
label: 'Subtitle',
default: 'Build something amazing with BlocksWeb'
},
{
type: 'text',
name: 'buttonText',
label: 'Button Text',
default: 'Get Started'
},
{
type: 'text',
name: 'buttonUrl',
label: 'Button URL',
default: '/signup'
}
]
};
export default Hero;Step 8: Register Your Component
Open blocksweb.config.ts and register your new component:
import { IBlockswebComponent } from '@blocksweb/core';
import Hero from './components/Hero';
export const editorComponents: IBlockswebComponent[] = [
Hero,
// Add more components here
];
export const settings = {
editorComponents,
scripts: ['https://cdn.tailwindcss.com'], // For styling
};Step 9: Use Your Component
- Go back to your browser at http://localhost:3000
- Click the "+ Add Block" button
- Find "Hero Section" in the component list
- Click to add it to the page
- You should see your hero component appear!
Step 10: Edit in the Visual Editor
Now the magic happens:
- Click on your hero component in the canvas
- The property panel opens on the right
- Change the title to "My Awesome Website"
- Change the subtitle to "Let's build something great"
- Watch it update in real-time!
Next Steps
Congratulations! You've created your first BlocksWeb project and component. Here's what to explore next:
Learn Core Concepts
- Components & Schema - Deep dive into component architecture
- Options System - Learn about all 12 option types
- Data Flow - Understand how props flow from editor
- Localization - Build multi-language sites
Build More Components
- Creating Components - Best practices for building components
- Options Reference - Complete reference for all 12 option types
- Utilities - Use RichText, Image, and other utilities
Add Collections
- Collections Overview - Add structured content
- Defining Collections - Create product catalogs, blogs, etc.
- Collection Providers - Setup data sources
Deploy to Production
- Vercel Deployment - Deploy to Vercel with BlocksWeb
Troubleshooting
API Key Not Working
Make sure your .env.local file is in the project root and the variable names are correct:
BLOCKSWEB_API_KEY=...
BLOCKSWEB_WORKSPACE_ID=...Restart the dev server after adding environment variables.
Component Not Appearing
- Check that the component is exported as default
- Verify it's registered in
blocksweb.config.ts - Make sure it has a
schemaproperty - Refresh your browser
TypeScript Errors
If you see TypeScript errors, run:
npm run type-checkThis will show you exactly what needs to be fixed.
Get Help
- Documentation: docs.blocksweb.nl
- GitHub Issues: github.com/blockswebnl/blocksweb/issues
- Discord Community: discord.gg/blocksweb
Now you're ready to build amazing things with BlocksWeb!