A browser-based JavaScript/TypeScript playground with a Chrome DevTools-like console. Built with React and TypeScript, this playground allows you to experiment with code and see the results in real-time.
- π Real-time code execution
- π― TypeScript support with live transpilation
- π οΈ Chrome DevTools-style console output
- π Detailed error handling and stack traces
- π Rich formatting for complex data types:
- Promises with state tracking
- Functions with full body display
- Objects and Arrays
- Primitive types with syntax highlighting
- β‘ Auto-run capability
- π¨ Syntax highlighting
- π± Progressive Web App (PWA) support
- π Offline capability with smart caching:
- Monaco editor resources
- Application assets
- Intelligent cache management
- Automatic cache updates
-
Clone the repository
git clone https://github.com/aakashdinkarh/js-ts-playground.git cd js-ts-playground
-
Install dependencies
npm install # or yarn install
-
Start the development server
npm run start # or yarn start
-
Open your browser and navigate to
http://localhost:3000
- Write your JavaScript or TypeScript code in the editor
- Code will auto-execute as you type (if enabled)
- View results in the console output below
- Use console methods like
console.log()
,console.error()
, etc. - Toggle TypeScript support using the language selector
// Basic example
console.log("Hello, World!");
// Promise example
async function fetchData() {
const response = await fetch('https://api.example.com/data');
const data = await response.json();
console.log(data);
}
// Object inspection
const user = {
name: 'John Doe',
age: 30,
roles: ['admin', 'user']
};
console.log(user);
The playground implements a sophisticated caching strategy that enables:
- β‘ Fast loading times with cached resources
- π Offline functionality
- π¦ Smart caching of:
- Monaco editor and TypeScript resources
- Application assets and static files
- Common file types (JS, CSS, images, fonts)
- π Intelligent cache management:
- Automatic background updates
- Non-blocking cache operations
- Graceful fallback to expired cache on network failure
- πΎ Two-tier caching system:
- Regular cache (24 hours) for application assets
- Long-term cache (7 days) for stable CDN resources
The playground will work even without an internet connection once you've visited it at least once. The service worker ensures optimal performance by:
- Pre-caching critical resources during installation
- Using a stale-while-revalidate strategy for dynamic content
- Managing cache cleanup and updates in the background
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with React
- Code editing powered by Monaco Editor
If you find any bugs or have feature requests, please create an issue in the GitHub repository.