Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
cdk-nextjs-export-s3-dynamic-routing
Advanced tools
Deploy a static export Next.js site to Cloudfront and S3 while maintaining the ability to use dynamic routes.
Have a more complex use case for Next.js 13? Perhaps check out cdk-nextjs-standalone.
Deploy a static export Next.js site to Cloudfront and S3 while maintaining the ability to use dynamic routes.
This effectively takes all of the benefits of Next.js, including routing, code-splitting, static HTML exporting, and also gives you the benefits of a SPA (single page application). This will be mostly useful for client-generated pages, but you can also partially server side generate some data should you choose.
This may also be useful if you use Next.js SSR in other frontends, and just want to keep a consistent experience for your developers.
You can use this construct effectively with no props, but here is a minimal example with a custom domain:
export class MyStaticSiteStack extends cdk.Stack {
private readonly hostedZone: route53.IHostedZone;
private readonly customDomainName: string;
private readonly site: NextjsExportS3DynamicRoutingSite;
constructor(scope: sst.App, id: string, props?: sst.StackProps) {
super(scope, id, props);
this.hostedZone = this.findHostedZone();
this.customDomainName = "yourdomain.com";
this.site = this.createNextJsSite();
this.createDnsRecord();
}
private findHostedZone(): route53.IHostedZone {
return route53.HostedZone.fromLookup(this, "HostedZone", {
domainName: this.customDomainName,
});
}
private createNextJsSite(): NextjsExportS3DynamicRoutingSite {
const certificate = new acm.Certificate(
this,
"Certificate",
{
domainName: this.customDomainName,
validation: acm.CertificateValidation.fromDns(this.hostedZone),
}
);
return new NextjsExportS3DynamicRoutingSite(this, "NextJsSite", {
distributionProps: {
certificate,
domainNames: [this.customDomainName],
}
});
}
private createDnsRecord = (): route53.ARecord => {
return new route53.ARecord(this, `AliasRecord`, {
recordName: this.customDomainName,
target: route53.RecordTarget.fromAlias(
new r53Targets.CloudFrontTarget(
this.site.cloudfrontDistribution
)
),
zone: this.hostedZone,
});
};
}
There are no outside requirements for this construct, and it will delete all of its resources when the stack is deleted.
FAQs
Deploy a static export Next.js site to Cloudfront and S3 while maintaining the ability to use dynamic routes.
We found that cdk-nextjs-export-s3-dynamic-routing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.