DEV Community

S Bhavi Vishnu
S Bhavi Vishnu

Posted on

Hosting React application using s3 and cloudfront

STEP 1:
1.1:check node and npmis already installed or not.if not, install npm and node.
1.2: Create a new project with vite build command ,Enter your project name
1.3:Select framework "REACT".
1.4:Select a varient "TYPESCRIPT".
1.5:Now run the above three commands.
Image description
STEP 2:Check localhost:5173
Image description
STEP 3:Now our react spplication is created successfully.
Image description
STEP 4:Open the project in vs code then run the command "npm run build".This command compiles and bundles your source code and placed in a directory dist.
STEP 5:Create a bucket with unique name.
Image description
Image description
STEP 6:enable static web hosting.
Image description
STEP 7:Add bucket policy.
Image description
STEP 8:Now upload the files and folders from the dist folder in your bucket.
Image description
STEP 9:Go to properties,scroll down,you can find bucket website endpoint,then click it.

Image description
STEP 10:our react application is hosted in s3.
Image description
STEP 11:Now create a cloudfront distribution for hosting a react application.
Image description
Image description
STEP 12:Copy the distribution domain name and paste it in a new tab.Now we can see the same result.
Image description
STEP 13:Finally delete the cloud front distribution.
Image description

Top comments (0)