Overview:
The SST SvelteKit Starter is a starter template for building a full stack application using SvelteKit and SST (Serverless Stack). It is designed and maintained by Okupter. SST is a framework that simplifies the process of building serverless applications on AWS by providing a simple, composable, and framework agnostic infrastructure. This starter template includes a SvelteKit application, an SST infrastructure, and various stacks that define the serverless infrastructure components such as API, authentication, RDS database, and S3 bucket.
Features:
- SvelteKit application: Includes a pre-configured SvelteKit application as the front-end of the full stack application.
- SST infrastructure: Provides a ready-to-use infrastructure setup using SST to define the serverless components.
- API stack: Defines the API infrastructure for handling backend requests.
- Authentication stack: Implements authentication functionality using Google OAuth.
- RDS Database stack: Sets up an RDS database for storing application data.
- S3 Bucket stack: Configures an S3 bucket for storing and serving static assets.
Installation:
To install and set up the SST SvelteKit Starter, follow these steps:
- Install the dependencies.
- Update the environment variables.
- Copy the
.env.examplefile to.envand update the values. - Set the
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYenvironment variables with your AWS account IAM user (with programmatic access) credentials. - Create an IAM user for SST with the necessary permissions by following the guide: Create an IAM User for SST.
- After setting the environment variables, SST will automatically load them for the local development setup.
- Set up Google OAuth by creating an application, OAuth client, and OAuth consent screen on https://console.cloud.google.com.
- Update the
.envfile with theGOOGLE_API_CLIENT_IDobtained from the Google OAuth setup. - Run the following command to set the secret into SST’s config secrets:
secret some-stack-gitlab-ci/cicd ~/my-secret-file.txt - Update the OAuth authorized domains and callback URL.
- Run
pnpm sst devto start the SST environment locally and obtain the API stack URL from the terminal output. - Update the “Authorized domains” option in the OAuth consent screen of your Google application with the API stack URL.
- Update the “Authorized redirect URIs” of the OAuth client with the API stack URL suffixed with
/auth/google/callback. - In another terminal, run the SvelteKit application.
- Access the SST Console at
https://console.sst.dev/sst-sveltekit-starter(replacesst-sveltekit-starterwith the actual name of the SST infrastructure defined insst.config.ts).
Summary:
The SST SvelteKit Starter is a comprehensive starter template for building full stack applications with SvelteKit and SST. It provides the necessary infrastructure and configurations to get started quickly. The template includes features such as a pre-configured SvelteKit application, authentication using Google OAuth, and infrastructure stacks for API, RDS database, and S3 bucket. The installation process involves setting up dependencies, environment variables, and configuring Google OAuth. With this starter template, developers can easily start building and deploying serverless applications on AWS.