This is an Astro starter project with a headstart for creating server-rendered web apps. I have been using this pattern for creating fairly simple web apps and deploying them on Ubuntu VPS servers.
- Astro with server-side rendering (with
@astrojs/node
adapter) - sqlite database using
better-sqlite3
library with script for initialising (initialise-db.js
) and helper functions for CRUD actions (seesrc/utils/db.js
) - Example routes for CRUD actions:
- index of notes
src/pages/notes/index.astro
- view note
src/pages/notes/[id]/index.astro
- edit note
src/pages/notes/[id]/edit.astro
- index of notes
- asynchronous task processing with
bullmq
library. can add jobs to queue inside Astro routes / API endpoints, and then the queue handles those jobs. - simple
<Layout>
component with status messages - simple
<Dump>
component for viewing variables in dev - import alias
@src
pointing to src folder for simple imports
git clone
this repository- to initialise database, edit the SQL create statements in
initialise-db.js
and then runnode initialise-db.js
- for asynchronous task processing:
- install Redis
- edit tasks in
consume-tasks.js
and runnode consume-tasks.js
npm run dev
to start up Astro dev server
- Set up example async tasks. File upload and then process?
- Instructions for deploying on a VPS server
- Setting up pm2
- Nginx configuration
- Process for making changes
npm create astro@latest -- --template minimal
🧑🚀 Seasoned astronaut? Delete this file. Have fun!
Inside of your Astro project, you'll see the following folders and files:
/
├── public/
├── src/
│ └── pages/
│ └── index.astro
└── package.json
Astro looks for .astro
or .md
files in the src/pages/
directory. Each page is exposed as a route based on its file name.
There's nothing special about src/components/
, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
Any static assets, like images, can be placed in the public/
directory.
All commands are run from the root of the project, from a terminal:
Command | Action |
---|---|
npm install |
Installs dependencies |
npm run dev |
Starts local dev server at localhost:3000 |
npm run build |
Build your production site to ./dist/ |
npm run preview |
Preview your build locally, before deploying |
npm run astro ... |
Run CLI commands like astro add , astro check |
npm run astro -- --help |
Get help using the Astro CLI |
Feel free to check our documentation or jump into our Discord server.