sst icon indicating copy to clipboard operation
sst copied to clipboard

[NextjsSite] Using custom L2 constructs in NextjsSite

Open guillaumeduboc opened this issue 2 years ago • 0 comments

First of all thanks a lot for all the impressive work on SST!

In my current project I have a library of L2 constructs enforcing some configuration for Lambda functions, buckets, distributions, etc. I'd like to use them as building blocks inside the NextjsSite.

Have you thought about how the construct can build on top of such custom constructs?

From what I read, a first possibility would be to extend the NextjsSite and overwrite methods creating resources. This would require to change private methods to protected. It's not great in the long run as the extension would copy some of the logic that you guys have created.

To go a step further, I thought we could use create functions such as https://github.com/serverless-stack/sst/blob/d615080013d8fc09d1bfc93bfe53284866d71c5f/packages/sst/src/constructs/SsrSite.ts#L711-L727 for basic resources (distribution, lambdas, queue). A user that want to use its custom L2 constructs would simply override these protected create methods.

What do you think ?

guillaumeduboc avatar Jun 22 '23 17:06 guillaumeduboc