SSR with Astro - Part 1, Introduction
Introduction for SSR with Astro, showing Astro's special features over other default solutions for SSR
Wed, May 01, 2024
-->
Create your first Astro project:
$ npm create astro@latest
You’ll find Hueston (Astro’s Cli) helping you out. Choose the recommended skeleton, choose whether you’ll use TypeScript or not (choose strict if so), and install dependencies.
You’ll have something like:
Now we’ll install Vuejs with Astro’s Cli:
$ npx astro add vue node
It’ll add Vuejs integration, so we can use Vuejs and .vue files, the Nodejs integration is to serve the SSR website.
// astro.config.mjs
export default defineConfig({
// ................
integrations: [vue()],
output: "hybrid",
adapter: node({
mode: "standalone",
}),
// ....................
});
We need to choose our output strategey and adapter mode:
In the src file, we’ll have three main files inside it:
Usually I use SCSS for styling, you only need to install:
$ npm install sass
Then declare the style language in your Astro component:
<style lang="scss"></style>
If you’re using Tailwind, check Astro’s integeration. All you need to start is:
$ npx astro add tailwind