🚀 Getting Started with StoneJS Framework
This guide will help you get up and running with StoneJS Framework quickly. Follow these steps to install, configure, and start building your first application.
1. Prerequisites
Before you begin, make sure you have:
- Node.js (version 14 or higher) - Download here
- npm or yarn package manager
- Basic knowledge of JavaScript and HTML
- (Optional) PostgreSQL database for database features
2. Installation
Option A: Clone the Repository
Option B: Install via NPM (when published)
3. Project Structure
Create the following directory structure for your application:
4. Create Your First Server
Create a server.js file in your project root:
That's it! This simple configuration gives you:
- Component-based page serving from
./pages - Template caching for better performance
- Auto-reload during development
- Session management
- Built-in caching
5. Create Your First Page
Create pages/index.html:
6. Start the Server
Open your browser and navigate to http://localhost:3000 - you should see your page!
✅ Congratulations! Your StoneJS application is now running.
7. Configuration Options
Customize your StoneJS application with these configuration options:
8. Environment Variables (.env)
Create a .env file for sensitive configuration:
Then install and use dotenv:
9. Add a Layout with Autohandler
Create pages/autohandler to wrap all pages with a consistent layout:
Now all pages will automatically be wrapped in this layout!
10. Next Steps
Now that you have the basics, explore these features:
- Framework Features - See all available features
- Autohandlers - Learn about hierarchical layouts
- Dhandlers - Build REST APIs and dynamic routing
- Section Tags - Organize your code with special tags
- Session Management - Work with user sessions
- Caching - Improve performance with caching
- Database Integration - Connect to PostgreSQL
- Include System - Reuse components
11. Development vs Production
Development Mode
Production Mode
12. Common Issues
Port Already in Use
Error: EADDRINUSE: address already in use
Solution: Change the port in your configuration or kill the process using the port:
Database Connection Failed
Error: Database connection errors
Solution:
- Verify your database is running
- Check .env file credentials
- Ensure the database exists
- Test connection with psql or database client
Template Not Found
Error: 404 Not Found
Solution:
- Verify the file exists in your
pages/directory - Check file extension (.html, .ejs, etc.)
- Ensure the path matches the URL
13. Getting Help
Need help?
- 📚 Browse the Interactive Documentation
- 💬 Join our community (Discord/Slack link)
- 🐛 Report issues on GitHub
- 📖 Read the Deployment Guide
Quick Reference Card
| Feature | Code |
|---|---|
| Run code | <% code %> |
| Output value | <%= value %> |
| Output HTML | <%- html %> |
| Include component | <% await include('/path') %> |
| Next in chain | <%- await next() %> |
| Session data | $session.key |
| Database query | await $db.query(sql, params) |
| Cache data | await $cache.remember(key, ttl, fn) |
| Context data | $context.set/get(key) |
You're all set! Start building your application with StoneJS Framework.
Happy coding! 🎉