Quick Start
Get up and running with bxn start in just a few minutes.
Create a New Project
Section titled “Create a New Project”The fastest way to get started is using the create-bxn init command:
pnpm create bxn@latestnpm create bxn@latestyarn create bxn@latestOnce created, start the development server:
cd your-project-namepnpm devcd your-project-namenpm run devcd your-project-nameyarn devVisit http://localhost:3000 in your browser to see your API running!
Manual Installation
Section titled “Manual Installation”If you prefer to set up manually, install both the framework and CLI:
pnpm add @buildxn/httppnpm add -D bxnnpm install @buildxn/httpnpm install -D bxnyarn add @buildxn/httpyarn add -D bxnThen add these scripts to your package.json:
{ "scripts": { "dev": "bxn start --watch", "start": "bxn start", "build": "tsc" }}Create Your First Route
Section titled “Create Your First Route”Create a simple route file at src/routes/get.ts:
import { route, json } from '@buildxn/http';
export default route().handle(() => { return json({ message: 'Hello, World!', timestamp: new Date().toISOString(), });});Run the Development Server
Section titled “Run the Development Server”Start the development server with watch mode for auto-reload:
npx bxn start --watchYour API is now running at http://localhost:3000!
Test Your API
Section titled “Test Your API”Open your browser or use curl to test the endpoint:
curl http://localhost:3000You should see:
{ "message": "Hello, World!", "timestamp": "2024-01-15T10:30:00.000Z"}Next Steps
Section titled “Next Steps”- Learn about File-System Routing to understand how routes are mapped
- Explore Request Handlers to build more complex APIs
- Check out the Response Helpers reference for all available response types